diff --git a/WiiUseJC_0.1/.cproject b/WiiUseJC_0.1/.cproject deleted file mode 100644 index c46ae82..0000000 --- a/WiiUseJC_0.1/.cproject +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - - - diff --git a/WiiUseJC_0.1/.project b/WiiUseJC_0.1/.project deleted file mode 100644 index 0f99eae..0000000 --- a/WiiUseJC_0.1/.project +++ /dev/null @@ -1,69 +0,0 @@ - - - WiiUseJavaC - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/WiiUseJavaC/Debug} - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.append_environment - true - - - ?name? - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.cnature - - diff --git a/WiiUseJC_0.1/lib/wiiuse.lib b/WiiUseJC_0.1/lib/wiiuse.lib deleted file mode 100644 index c997396..0000000 Binary files a/WiiUseJC_0.1/lib/wiiuse.lib and /dev/null differ diff --git a/WiiUseJC_0.1/wiiuse.h b/WiiUseJC_0.1/wiiuse.h deleted file mode 100644 index 6071635..0000000 --- a/WiiUseJC_0.1/wiiuse.h +++ /dev/null @@ -1,632 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -#ifdef _WIN32 - /* windows */ - #include -#else - /* nix */ - #include -#endif - -#ifdef WIIUSE_INTERNAL_H_INCLUDED - #define WCONST -#else - #define WCONST const -#endif - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 -#define NUNCHUK_BUTTON_ALL 0x03 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 -#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF - -/* guitar hero 3 button codes */ -#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 -#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008 -#define GUITAR_HERO_3_BUTTON_GREEN 0x0010 -#define GUITAR_HERO_3_BUTTON_BLUE 0x0020 -#define GUITAR_HERO_3_BUTTON_RED 0x0040 -#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080 -#define GUITAR_HERO_3_BUTTON_PLUS 0x0400 -#define GUITAR_HERO_3_BUTTON_MINUS 0x1000 -#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 -#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF - - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -#define WIIUSE_ORIENT_PRECISION 100.0f - -/* expansion codes */ -#define EXP_NONE 0 -#define EXP_NUNCHUK 1 -#define EXP_CLASSIC 2 -#define EXP_GUITAR_HERO_3 3 - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) -#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) - -#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -/* - * This is left over from an old hack, but it may actually - * be a useful feature to keep so it wasn't removed. - */ -#ifdef WIN32 - #define WIIMOTE_DEFAULT_TIMEOUT 10 - #define WIIMOTE_EXP_TIMEOUT 10 -#endif - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; /**< roll, this may be smoothed if enabled */ - float pitch; /**< pitch, this may be smoothed if enabled */ - float yaw; - - float a_roll; /**< absolute roll, unsmoothed */ - float a_pitch; /**< absolute pitch, unsmoothed */ -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< 1g difference around 0cal */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - float orient_threshold; /**< threshold for orient to generate an event */ - int accel_threshold; /**< threshold for accel to generate an event */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct guitar_hero_3_t - * @brief Guitar Hero 3 expansion device. - */ -typedef struct guitar_hero_3_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float whammy_bar; /**< whammy bar (range 0-1) */ - - struct joystick_t js; /**< joystick calibration */ -} guitar_hero_3_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - int type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - struct guitar_hero_3_t gh3; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -/** - * @struct wiimote_state_t - * @brief Significant data from the previous event. - */ -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - unsigned short exp_btns; - struct orient_t exp_orient; - struct vec3b_t exp_accel; - float exp_r_shoulder; - float exp_l_shoulder; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; - - struct vec3b_t accel; -} wiimote_state_t; - - -/** - * @enum WIIUSE_EVENT_TYPE - * @brief Events that wiiuse can generate from a poll. - */ -typedef enum WIIUSE_EVENT_TYPE { - WIIUSE_NONE = 0, - WIIUSE_EVENT, - WIIUSE_STATUS, - WIIUSE_DISCONNECT, - WIIUSE_NUNCHUK_INSERTED, - WIIUSE_NUNCHUK_REMOVED, - WIIUSE_CLASSIC_CTRL_INSERTED, - WIIUSE_CLASSIC_CTRL_REMOVED, - WIIUSE_GUITAR_HERO_3_CTRL_INSERTED, - WIIUSE_GUITAR_HERO_3_CTRL_REMOVED -} WIIUSE_EVENT_TYPE; - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ - #endif - - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ - - WCONST int flags; /**< options flag */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int accel_threshold; /**< threshold for accel to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */ - WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef _WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) -#else - #define WIIUSE_EXPORT_DECL - #define WIIUSE_IMPORT_DECL -#endif - -#ifdef WIIUSE_COMPILE_LIB - #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL -#else - #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -WIIUSE_EXPORT extern const char* wiiuse_version(); - -WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds); -WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int offset, unsigned short len); -WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm); -WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid); -WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable); -WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha); -WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); -WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); - -/* connect.c */ -WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); -WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); - -/* events.c */ -WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); - -/* ir.c */ -WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); -WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos); -WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect); - -/* nunchuk.c */ -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct nunchuk_t* nc, float threshold); -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct nunchuk_t* nc, int threshold); - - -#ifdef __cplusplus -} -#endif - - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/WiiUseJC_0.1/wiiusej_WiiUseApi.c b/WiiUseJC_0.1/wiiusej_WiiUseApi.c deleted file mode 100644 index 40319fd..0000000 --- a/WiiUseJC_0.1/wiiusej_WiiUseApi.c +++ /dev/null @@ -1,476 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -#ifndef WIN32 -#include -#define WIIUSE_PATH "./wiiuse.so" -#else -#define WIIUSE_PATH "wiiuse.dll" -#endif - -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" -/* - * These are some identifiers for wiimotes - * - * See below in main() for what they are used for. - */ -#define WIIMOTE_STATE_RUMBLE 0x08 -#define WIIMOTE_STATE_CONNECTED 0x04 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) - -/********************* VARIABLES DECLARATIONS *****************************/ - -/* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. - */ -static wiimote** wiimotes; - -static int nbMaxWiiMotes=0; - -/****************** GENERAL FUNCTIONS DEFINITIONS *************************/ - -/** - * Try to connect to 2 wiimotes. - * Make them rumble to show they are connected. - * @param nbConnects number of connections maximum. - * @return 0 if there is an error otherwise it returns - * the number of wiimotes connected.. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections -(JNIEnv *env, jobject obj, jint nbConnects) { - - /* variables declarations */ - int found, connected, i; - short leds; - - nbMaxWiiMotes = nbConnects; - - /* initialize wiimotes array with the maximum number of wiimotes */ - wiimotes = wiiuse_init(nbMaxWiiMotes); - - /* - * Find wiimote devices - * Now we need to find some wiimotes. - * Give the function the wiimote array we created, and tell it there - * are 2 wiimotes we are interested in. - * Set the timeout to be 5 seconds. - * This will return the number of actual wiimotes that are in discovery mode. - */ - found = wiiuse_find(wiimotes, nbMaxWiiMotes, 5); - if (!found) return 0; - - /* - * Connect to the wiimotes - * Now that we found some wiimotes, connect to them. - * Give the function the wiimote array and the number of wiimote devices we found. - * This will return the number of established connections to the found wiimotes. - */ - connected = wiiuse_connect(wiimotes, nbMaxWiiMotes); - if (!connected) return 0; - - //no problems during connection show that wiimotes are connected - - /* - * Now set the LEDs and rumble for a second so it's easy - * to tell which wiimotes are connected (just like the wii does). - */ - for (i=0;iGetObjectClass(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 = 0; - - mid = (*env)->GetMethodID(env, cls, "prepareIRevent", - "(IIIIIIIIISS)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); - - mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", - "(IISSS)V"); - if (mid == 0) { - return; - } - /* go through each of the 4 possible IR sources */ - for (; 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", "(FIZFFFFFFFSSS)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]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z, - wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z); - } - - /* 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_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; - - 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; - - default: - break; - } - } - } -} diff --git a/WiiUseJC_0.1/wiiusej_WiiUseApi.def b/WiiUseJC_0.1/wiiusej_WiiUseApi.def deleted file mode 100644 index a83a234..0000000 --- a/WiiUseJC_0.1/wiiusej_WiiUseApi.def +++ /dev/null @@ -1,27 +0,0 @@ -EXPORTS -Java_wiiusej_WiiUseApi_doConnections -Java_wiiusej_WiiUseApi_closeConnection -Java_wiiusej_WiiUseApi_shutdownApi -Java_wiiusej_WiiUseApi_activateRumble -Java_wiiusej_WiiUseApi_deactivateRumble -Java_wiiusej_WiiUseApi_activateIRTracking -Java_wiiusej_WiiUseApi_deactivateIRTracking -Java_wiiusej_WiiUseApi_activateMotionSensing -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_setLeds -Java_wiiusej_WiiUseApi_setOrientThreshold -Java_wiiusej_WiiUseApi_setAccelThreshold -Java_wiiusej_WiiUseApi_setAlphaSmoothing -Java_wiiusej_WiiUseApi_reSync -Java_wiiusej_WiiUseApi_activateSmoothing -Java_wiiusej_WiiUseApi_deactivateSmoothing -Java_wiiusej_WiiUseApi_activateContinuous -Java_wiiusej_WiiUseApi_deactivateContinuous -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_getStatus -Java_wiiusej_WiiUseApi_specialPoll -Java_wiiusej_WiiUseApi_setScreenRatio43 -Java_wiiusej_WiiUseApi_setScreenRatio169 -Java_wiiusej_WiiUseApi_setSensorBarAboveScreen -Java_wiiusej_WiiUseApi_setSensorBarBelowScreen -Java_wiiusej_WiiUseApi_setVirtualScreenResolution diff --git a/WiiUseJC_0.1/wiiusej_WiiUseApi.h b/WiiUseJC_0.1/wiiusej_WiiUseApi.h deleted file mode 100644 index fdf22a6..0000000 --- a/WiiUseJC_0.1/wiiusej_WiiUseApi.h +++ /dev/null @@ -1,213 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class wiiusej_WiiUseApi */ - -#ifndef _Included_wiiusej_WiiUseApi -#define _Included_wiiusej_WiiUseApi -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: wiiusej_WiiUseApi - * Method: doConnections - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: closeConnection - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: shutdownApi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setLeds - * Signature: (IZZZZ)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds - (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: setOrientThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAccelThreshold - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAlphaSmoothing - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: reSync - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio43 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio169 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarAboveScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarBelowScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setVirtualScreenResolution - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getStatus - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: specialPoll - * Signature: (Lwiiusej/wiiuseapievents/EventsGatherer;)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/WiiUseJC_0.11/.cproject b/WiiUseJC_0.11/.cproject deleted file mode 100644 index 1ca9232..0000000 --- a/WiiUseJC_0.11/.cproject +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - - - diff --git a/WiiUseJC_0.11/.project b/WiiUseJC_0.11/.project deleted file mode 100644 index 0f99eae..0000000 --- a/WiiUseJC_0.11/.project +++ /dev/null @@ -1,69 +0,0 @@ - - - WiiUseJavaC - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/WiiUseJavaC/Debug} - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.append_environment - true - - - ?name? - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.cnature - - diff --git a/WiiUseJC_0.11/lib/wiiuse.lib b/WiiUseJC_0.11/lib/wiiuse.lib deleted file mode 100644 index c997396..0000000 Binary files a/WiiUseJC_0.11/lib/wiiuse.lib and /dev/null differ diff --git a/WiiUseJC_0.11/wiiuse.h b/WiiUseJC_0.11/wiiuse.h deleted file mode 100644 index 6071635..0000000 --- a/WiiUseJC_0.11/wiiuse.h +++ /dev/null @@ -1,632 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -#ifdef _WIN32 - /* windows */ - #include -#else - /* nix */ - #include -#endif - -#ifdef WIIUSE_INTERNAL_H_INCLUDED - #define WCONST -#else - #define WCONST const -#endif - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 -#define NUNCHUK_BUTTON_ALL 0x03 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 -#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF - -/* guitar hero 3 button codes */ -#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 -#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008 -#define GUITAR_HERO_3_BUTTON_GREEN 0x0010 -#define GUITAR_HERO_3_BUTTON_BLUE 0x0020 -#define GUITAR_HERO_3_BUTTON_RED 0x0040 -#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080 -#define GUITAR_HERO_3_BUTTON_PLUS 0x0400 -#define GUITAR_HERO_3_BUTTON_MINUS 0x1000 -#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 -#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF - - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -#define WIIUSE_ORIENT_PRECISION 100.0f - -/* expansion codes */ -#define EXP_NONE 0 -#define EXP_NUNCHUK 1 -#define EXP_CLASSIC 2 -#define EXP_GUITAR_HERO_3 3 - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) -#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) - -#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -/* - * This is left over from an old hack, but it may actually - * be a useful feature to keep so it wasn't removed. - */ -#ifdef WIN32 - #define WIIMOTE_DEFAULT_TIMEOUT 10 - #define WIIMOTE_EXP_TIMEOUT 10 -#endif - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; /**< roll, this may be smoothed if enabled */ - float pitch; /**< pitch, this may be smoothed if enabled */ - float yaw; - - float a_roll; /**< absolute roll, unsmoothed */ - float a_pitch; /**< absolute pitch, unsmoothed */ -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< 1g difference around 0cal */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - float orient_threshold; /**< threshold for orient to generate an event */ - int accel_threshold; /**< threshold for accel to generate an event */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct guitar_hero_3_t - * @brief Guitar Hero 3 expansion device. - */ -typedef struct guitar_hero_3_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float whammy_bar; /**< whammy bar (range 0-1) */ - - struct joystick_t js; /**< joystick calibration */ -} guitar_hero_3_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - int type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - struct guitar_hero_3_t gh3; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -/** - * @struct wiimote_state_t - * @brief Significant data from the previous event. - */ -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - unsigned short exp_btns; - struct orient_t exp_orient; - struct vec3b_t exp_accel; - float exp_r_shoulder; - float exp_l_shoulder; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; - - struct vec3b_t accel; -} wiimote_state_t; - - -/** - * @enum WIIUSE_EVENT_TYPE - * @brief Events that wiiuse can generate from a poll. - */ -typedef enum WIIUSE_EVENT_TYPE { - WIIUSE_NONE = 0, - WIIUSE_EVENT, - WIIUSE_STATUS, - WIIUSE_DISCONNECT, - WIIUSE_NUNCHUK_INSERTED, - WIIUSE_NUNCHUK_REMOVED, - WIIUSE_CLASSIC_CTRL_INSERTED, - WIIUSE_CLASSIC_CTRL_REMOVED, - WIIUSE_GUITAR_HERO_3_CTRL_INSERTED, - WIIUSE_GUITAR_HERO_3_CTRL_REMOVED -} WIIUSE_EVENT_TYPE; - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ - #endif - - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ - - WCONST int flags; /**< options flag */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int accel_threshold; /**< threshold for accel to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */ - WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef _WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) -#else - #define WIIUSE_EXPORT_DECL - #define WIIUSE_IMPORT_DECL -#endif - -#ifdef WIIUSE_COMPILE_LIB - #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL -#else - #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -WIIUSE_EXPORT extern const char* wiiuse_version(); - -WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds); -WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int offset, unsigned short len); -WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm); -WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid); -WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable); -WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha); -WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); -WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); - -/* connect.c */ -WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); -WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); - -/* events.c */ -WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); - -/* ir.c */ -WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); -WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos); -WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect); - -/* nunchuk.c */ -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct nunchuk_t* nc, float threshold); -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct nunchuk_t* nc, int threshold); - - -#ifdef __cplusplus -} -#endif - - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/WiiUseJC_0.11/wiiusej_WiiUseApi.c b/WiiUseJC_0.11/wiiusej_WiiUseApi.c deleted file mode 100644 index be218e7..0000000 --- a/WiiUseJC_0.11/wiiusej_WiiUseApi.c +++ /dev/null @@ -1,477 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -#ifndef WIN32 - #include -#else - -#endif - -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" -/* - * These are some identifiers for wiimotes - * - * See below in main() for what they are used for. - */ -#define WIIMOTE_STATE_RUMBLE 0x08 -#define WIIMOTE_STATE_CONNECTED 0x04 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) - -/********************* VARIABLES DECLARATIONS *****************************/ - -/* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. - */ -static wiimote** wiimotes; - -static int nbMaxWiiMotes=0; - -/****************** GENERAL FUNCTIONS DEFINITIONS *************************/ - -/** - * Try to connect to 2 wiimotes. - * Make them rumble to show they are connected. - * @param nbConnects number of connections maximum. - * @param rumble - * make the connected wiimotes rumble. - * @return 0 if there is an error otherwise it returns - * the number of wiimotes connected.. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections -(JNIEnv *env, jobject obj, jint nbConnects, jboolean rumble) { - - /* variables declarations */ - int found, connected, i; - short leds; - - nbMaxWiiMotes = nbConnects; - - /* initialize wiimotes array with the maximum number of wiimotes */ - wiimotes = wiiuse_init(nbMaxWiiMotes); - - /* - * Find wiimote devices - * Now we need to find some wiimotes. - * Give the function the wiimote array we created, and tell it there - * are 2 wiimotes we are interested in. - * Set the timeout to be 5 seconds. - * This will return the number of actual wiimotes that are in discovery mode. - */ - found = wiiuse_find(wiimotes, nbMaxWiiMotes, 5); - if (!found) return 0; - - /* - * Connect to the wiimotes - * Now that we found some wiimotes, connect to them. - * Give the function the wiimote array and the number of wiimote devices we found. - * This will return the number of established connections to the found wiimotes. - */ - connected = wiiuse_connect(wiimotes, nbMaxWiiMotes); - if (!connected) return 0; - - //no problems during connection show that wiimotes are connected - - /* - * Now set the LEDs and rumble for a second so it's easy - * to tell which wiimotes are connected (just like the wii does). - */ - for (i=0;iGetObjectClass(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 = 0; - - mid = (*env)->GetMethodID(env, cls, "prepareIRevent", - "(IIIIIIIIISS)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); - - mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", - "(IISSS)V"); - if (mid == 0) { - return; - } - /* go through each of the 4 possible IR sources */ - for (; 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", "(FIZFFFFFFFSSS)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]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z, - wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z); - } - - /* 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_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; - - 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; - - default: - break; - } - } - } -} diff --git a/WiiUseJC_0.11/wiiusej_WiiUseApi.def b/WiiUseJC_0.11/wiiusej_WiiUseApi.def deleted file mode 100644 index a83a234..0000000 --- a/WiiUseJC_0.11/wiiusej_WiiUseApi.def +++ /dev/null @@ -1,27 +0,0 @@ -EXPORTS -Java_wiiusej_WiiUseApi_doConnections -Java_wiiusej_WiiUseApi_closeConnection -Java_wiiusej_WiiUseApi_shutdownApi -Java_wiiusej_WiiUseApi_activateRumble -Java_wiiusej_WiiUseApi_deactivateRumble -Java_wiiusej_WiiUseApi_activateIRTracking -Java_wiiusej_WiiUseApi_deactivateIRTracking -Java_wiiusej_WiiUseApi_activateMotionSensing -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_setLeds -Java_wiiusej_WiiUseApi_setOrientThreshold -Java_wiiusej_WiiUseApi_setAccelThreshold -Java_wiiusej_WiiUseApi_setAlphaSmoothing -Java_wiiusej_WiiUseApi_reSync -Java_wiiusej_WiiUseApi_activateSmoothing -Java_wiiusej_WiiUseApi_deactivateSmoothing -Java_wiiusej_WiiUseApi_activateContinuous -Java_wiiusej_WiiUseApi_deactivateContinuous -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_getStatus -Java_wiiusej_WiiUseApi_specialPoll -Java_wiiusej_WiiUseApi_setScreenRatio43 -Java_wiiusej_WiiUseApi_setScreenRatio169 -Java_wiiusej_WiiUseApi_setSensorBarAboveScreen -Java_wiiusej_WiiUseApi_setSensorBarBelowScreen -Java_wiiusej_WiiUseApi_setVirtualScreenResolution diff --git a/WiiUseJC_0.11/wiiusej_WiiUseApi.h b/WiiUseJC_0.11/wiiusej_WiiUseApi.h deleted file mode 100644 index 9ee751c..0000000 --- a/WiiUseJC_0.11/wiiusej_WiiUseApi.h +++ /dev/null @@ -1,213 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class wiiusej_WiiUseApi */ - -#ifndef _Included_wiiusej_WiiUseApi -#define _Included_wiiusej_WiiUseApi -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: wiiusej_WiiUseApi - * Method: doConnections - * Signature: (IZ)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections - (JNIEnv *, jobject, jint, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: closeConnection - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: shutdownApi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setLeds - * Signature: (IZZZZ)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds - (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: setOrientThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAccelThreshold - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAlphaSmoothing - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: reSync - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio43 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio169 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarAboveScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarBelowScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setVirtualScreenResolution - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getStatus - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: specialPoll - * Signature: (Lwiiusej/wiiuseapievents/EventsGatherer;)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/WiiUseJC_0.11ThreadReqeuests/.cproject b/WiiUseJC_0.11ThreadReqeuests/.cproject deleted file mode 100644 index 1ca9232..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/.cproject +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - - - diff --git a/WiiUseJC_0.11ThreadReqeuests/.project b/WiiUseJC_0.11ThreadReqeuests/.project deleted file mode 100644 index 0f99eae..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/.project +++ /dev/null @@ -1,69 +0,0 @@ - - - WiiUseJavaC - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/WiiUseJavaC/Debug} - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.append_environment - true - - - ?name? - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.cnature - - diff --git a/WiiUseJC_0.11ThreadReqeuests/lib/wiiuse.lib b/WiiUseJC_0.11ThreadReqeuests/lib/wiiuse.lib deleted file mode 100644 index c997396..0000000 Binary files a/WiiUseJC_0.11ThreadReqeuests/lib/wiiuse.lib and /dev/null differ diff --git a/WiiUseJC_0.11ThreadReqeuests/wiiuse.h b/WiiUseJC_0.11ThreadReqeuests/wiiuse.h deleted file mode 100644 index 6071635..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/wiiuse.h +++ /dev/null @@ -1,632 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -#ifdef _WIN32 - /* windows */ - #include -#else - /* nix */ - #include -#endif - -#ifdef WIIUSE_INTERNAL_H_INCLUDED - #define WCONST -#else - #define WCONST const -#endif - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 -#define NUNCHUK_BUTTON_ALL 0x03 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 -#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF - -/* guitar hero 3 button codes */ -#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 -#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008 -#define GUITAR_HERO_3_BUTTON_GREEN 0x0010 -#define GUITAR_HERO_3_BUTTON_BLUE 0x0020 -#define GUITAR_HERO_3_BUTTON_RED 0x0040 -#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080 -#define GUITAR_HERO_3_BUTTON_PLUS 0x0400 -#define GUITAR_HERO_3_BUTTON_MINUS 0x1000 -#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 -#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF - - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -#define WIIUSE_ORIENT_PRECISION 100.0f - -/* expansion codes */ -#define EXP_NONE 0 -#define EXP_NUNCHUK 1 -#define EXP_CLASSIC 2 -#define EXP_GUITAR_HERO_3 3 - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) -#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) - -#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -/* - * This is left over from an old hack, but it may actually - * be a useful feature to keep so it wasn't removed. - */ -#ifdef WIN32 - #define WIIMOTE_DEFAULT_TIMEOUT 10 - #define WIIMOTE_EXP_TIMEOUT 10 -#endif - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; /**< roll, this may be smoothed if enabled */ - float pitch; /**< pitch, this may be smoothed if enabled */ - float yaw; - - float a_roll; /**< absolute roll, unsmoothed */ - float a_pitch; /**< absolute pitch, unsmoothed */ -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< 1g difference around 0cal */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - float orient_threshold; /**< threshold for orient to generate an event */ - int accel_threshold; /**< threshold for accel to generate an event */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct guitar_hero_3_t - * @brief Guitar Hero 3 expansion device. - */ -typedef struct guitar_hero_3_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float whammy_bar; /**< whammy bar (range 0-1) */ - - struct joystick_t js; /**< joystick calibration */ -} guitar_hero_3_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - int type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - struct guitar_hero_3_t gh3; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -/** - * @struct wiimote_state_t - * @brief Significant data from the previous event. - */ -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - unsigned short exp_btns; - struct orient_t exp_orient; - struct vec3b_t exp_accel; - float exp_r_shoulder; - float exp_l_shoulder; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; - - struct vec3b_t accel; -} wiimote_state_t; - - -/** - * @enum WIIUSE_EVENT_TYPE - * @brief Events that wiiuse can generate from a poll. - */ -typedef enum WIIUSE_EVENT_TYPE { - WIIUSE_NONE = 0, - WIIUSE_EVENT, - WIIUSE_STATUS, - WIIUSE_DISCONNECT, - WIIUSE_NUNCHUK_INSERTED, - WIIUSE_NUNCHUK_REMOVED, - WIIUSE_CLASSIC_CTRL_INSERTED, - WIIUSE_CLASSIC_CTRL_REMOVED, - WIIUSE_GUITAR_HERO_3_CTRL_INSERTED, - WIIUSE_GUITAR_HERO_3_CTRL_REMOVED -} WIIUSE_EVENT_TYPE; - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ - #endif - - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ - - WCONST int flags; /**< options flag */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int accel_threshold; /**< threshold for accel to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */ - WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef _WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) -#else - #define WIIUSE_EXPORT_DECL - #define WIIUSE_IMPORT_DECL -#endif - -#ifdef WIIUSE_COMPILE_LIB - #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL -#else - #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -WIIUSE_EXPORT extern const char* wiiuse_version(); - -WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds); -WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int offset, unsigned short len); -WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm); -WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid); -WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable); -WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha); -WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); -WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); - -/* connect.c */ -WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); -WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); - -/* events.c */ -WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); - -/* ir.c */ -WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); -WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos); -WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect); - -/* nunchuk.c */ -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct nunchuk_t* nc, float threshold); -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct nunchuk_t* nc, int threshold); - - -#ifdef __cplusplus -} -#endif - - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.c b/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.c deleted file mode 100644 index be218e7..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.c +++ /dev/null @@ -1,477 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -#ifndef WIN32 - #include -#else - -#endif - -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" -/* - * These are some identifiers for wiimotes - * - * See below in main() for what they are used for. - */ -#define WIIMOTE_STATE_RUMBLE 0x08 -#define WIIMOTE_STATE_CONNECTED 0x04 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) - -/********************* VARIABLES DECLARATIONS *****************************/ - -/* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. - */ -static wiimote** wiimotes; - -static int nbMaxWiiMotes=0; - -/****************** GENERAL FUNCTIONS DEFINITIONS *************************/ - -/** - * Try to connect to 2 wiimotes. - * Make them rumble to show they are connected. - * @param nbConnects number of connections maximum. - * @param rumble - * make the connected wiimotes rumble. - * @return 0 if there is an error otherwise it returns - * the number of wiimotes connected.. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections -(JNIEnv *env, jobject obj, jint nbConnects, jboolean rumble) { - - /* variables declarations */ - int found, connected, i; - short leds; - - nbMaxWiiMotes = nbConnects; - - /* initialize wiimotes array with the maximum number of wiimotes */ - wiimotes = wiiuse_init(nbMaxWiiMotes); - - /* - * Find wiimote devices - * Now we need to find some wiimotes. - * Give the function the wiimote array we created, and tell it there - * are 2 wiimotes we are interested in. - * Set the timeout to be 5 seconds. - * This will return the number of actual wiimotes that are in discovery mode. - */ - found = wiiuse_find(wiimotes, nbMaxWiiMotes, 5); - if (!found) return 0; - - /* - * Connect to the wiimotes - * Now that we found some wiimotes, connect to them. - * Give the function the wiimote array and the number of wiimote devices we found. - * This will return the number of established connections to the found wiimotes. - */ - connected = wiiuse_connect(wiimotes, nbMaxWiiMotes); - if (!connected) return 0; - - //no problems during connection show that wiimotes are connected - - /* - * Now set the LEDs and rumble for a second so it's easy - * to tell which wiimotes are connected (just like the wii does). - */ - for (i=0;iGetObjectClass(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 = 0; - - mid = (*env)->GetMethodID(env, cls, "prepareIRevent", - "(IIIIIIIIISS)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); - - mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", - "(IISSS)V"); - if (mid == 0) { - return; - } - /* go through each of the 4 possible IR sources */ - for (; 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", "(FIZFFFFFFFSSS)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]->gforce.x, wiimotes[i]->gforce.y, wiimotes[i]->gforce.z, - wiimotes[i]->accel.x, wiimotes[i]->accel.y, wiimotes[i]->accel.z); - } - - /* 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_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; - - 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; - - default: - break; - } - } - } -} diff --git a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.def b/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.def deleted file mode 100644 index a83a234..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.def +++ /dev/null @@ -1,27 +0,0 @@ -EXPORTS -Java_wiiusej_WiiUseApi_doConnections -Java_wiiusej_WiiUseApi_closeConnection -Java_wiiusej_WiiUseApi_shutdownApi -Java_wiiusej_WiiUseApi_activateRumble -Java_wiiusej_WiiUseApi_deactivateRumble -Java_wiiusej_WiiUseApi_activateIRTracking -Java_wiiusej_WiiUseApi_deactivateIRTracking -Java_wiiusej_WiiUseApi_activateMotionSensing -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_setLeds -Java_wiiusej_WiiUseApi_setOrientThreshold -Java_wiiusej_WiiUseApi_setAccelThreshold -Java_wiiusej_WiiUseApi_setAlphaSmoothing -Java_wiiusej_WiiUseApi_reSync -Java_wiiusej_WiiUseApi_activateSmoothing -Java_wiiusej_WiiUseApi_deactivateSmoothing -Java_wiiusej_WiiUseApi_activateContinuous -Java_wiiusej_WiiUseApi_deactivateContinuous -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_getStatus -Java_wiiusej_WiiUseApi_specialPoll -Java_wiiusej_WiiUseApi_setScreenRatio43 -Java_wiiusej_WiiUseApi_setScreenRatio169 -Java_wiiusej_WiiUseApi_setSensorBarAboveScreen -Java_wiiusej_WiiUseApi_setSensorBarBelowScreen -Java_wiiusej_WiiUseApi_setVirtualScreenResolution diff --git a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.h b/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.h deleted file mode 100644 index 9ee751c..0000000 --- a/WiiUseJC_0.11ThreadReqeuests/wiiusej_WiiUseApi.h +++ /dev/null @@ -1,213 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class wiiusej_WiiUseApi */ - -#ifndef _Included_wiiusej_WiiUseApi -#define _Included_wiiusej_WiiUseApi -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: wiiusej_WiiUseApi - * Method: doConnections - * Signature: (IZ)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections - (JNIEnv *, jobject, jint, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: closeConnection - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: shutdownApi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setLeds - * Signature: (IZZZZ)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds - (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: setOrientThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAccelThreshold - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAlphaSmoothing - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: reSync - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio43 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio169 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarAboveScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarBelowScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setVirtualScreenResolution - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getStatus - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: specialPoll - * Signature: (Lwiiusej/wiiuseapievents/EventsGatherer;)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/WiiUseJC_0.12/.cproject b/WiiUseJC_0.12/.cproject deleted file mode 100644 index 1ca9232..0000000 --- a/WiiUseJC_0.12/.cproject +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - - - diff --git a/WiiUseJC_0.12/.project b/WiiUseJC_0.12/.project deleted file mode 100644 index 0f99eae..0000000 --- a/WiiUseJC_0.12/.project +++ /dev/null @@ -1,69 +0,0 @@ - - - WiiUseJavaC - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/WiiUseJavaC/Debug} - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.append_environment - true - - - ?name? - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.cnature - - diff --git a/WiiUseJC_0.12/lib/wiiuse.lib b/WiiUseJC_0.12/lib/wiiuse.lib deleted file mode 100644 index 4f1b69b..0000000 Binary files a/WiiUseJC_0.12/lib/wiiuse.lib and /dev/null differ diff --git a/WiiUseJC_0.12/wiiuse.h b/WiiUseJC_0.12/wiiuse.h deleted file mode 100644 index 9dff81c..0000000 --- a/WiiUseJC_0.12/wiiuse.h +++ /dev/null @@ -1,653 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -#ifdef _WIN32 - /* windows */ - #include -#else - /* nix */ - #include -#endif - -#ifdef WIIUSE_INTERNAL_H_INCLUDED - #define WCONST -#else - #define WCONST const -#endif - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 -#define NUNCHUK_BUTTON_ALL 0x03 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 -#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF - -/* guitar hero 3 button codes */ -#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 -#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008 -#define GUITAR_HERO_3_BUTTON_GREEN 0x0010 -#define GUITAR_HERO_3_BUTTON_BLUE 0x0020 -#define GUITAR_HERO_3_BUTTON_RED 0x0040 -#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080 -#define GUITAR_HERO_3_BUTTON_PLUS 0x0400 -#define GUITAR_HERO_3_BUTTON_MINUS 0x1000 -#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 -#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF - - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -#define WIIUSE_ORIENT_PRECISION 100.0f - -/* expansion codes */ -#define EXP_NONE 0 -#define EXP_NUNCHUK 1 -#define EXP_CLASSIC 2 -#define EXP_GUITAR_HERO_3 3 - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -/** - * @brief Return the IR sensitivity level. - * @param wm Pointer to a wiimote_t structure. - * @param lvl [out] Pointer to an int that will hold the level setting. - * If no level is set 'lvl' will be set to 0. - */ -#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \ - do { \ - if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ - else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ - else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ - else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ - else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ - else *lvl = 0; \ - } while (0) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) -#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) - -#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -/* - * This is left over from an old hack, but it may actually - * be a useful feature to keep so it wasn't removed. - */ -#ifdef WIN32 - #define WIIMOTE_DEFAULT_TIMEOUT 10 - #define WIIMOTE_EXP_TIMEOUT 10 -#endif - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - byte dirty; /**< set to 1 if not using callback and needs to be cleaned up */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; /**< roll, this may be smoothed if enabled */ - float pitch; /**< pitch, this may be smoothed if enabled */ - float yaw; - - float a_roll; /**< absolute roll, unsmoothed */ - float a_pitch; /**< absolute pitch, unsmoothed */ -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< 1g difference around 0cal */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - float orient_threshold; /**< threshold for orient to generate an event */ - int accel_threshold; /**< threshold for accel to generate an event */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct guitar_hero_3_t - * @brief Guitar Hero 3 expansion device. - */ -typedef struct guitar_hero_3_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float whammy_bar; /**< whammy bar (range 0-1) */ - - struct joystick_t js; /**< joystick calibration */ -} guitar_hero_3_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - int type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - struct guitar_hero_3_t gh3; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -/** - * @struct wiimote_state_t - * @brief Significant data from the previous event. - */ -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - unsigned short exp_btns; - struct orient_t exp_orient; - struct vec3b_t exp_accel; - float exp_r_shoulder; - float exp_l_shoulder; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; - - struct vec3b_t accel; -} wiimote_state_t; - - -/** - * @enum WIIUSE_EVENT_TYPE - * @brief Events that wiiuse can generate from a poll. - */ -typedef enum WIIUSE_EVENT_TYPE { - WIIUSE_NONE = 0, - WIIUSE_EVENT, - WIIUSE_STATUS, - WIIUSE_CONNECT, - WIIUSE_DISCONNECT, - WIIUSE_UNEXPECTED_DISCONNECT, - WIIUSE_READ_DATA, - WIIUSE_NUNCHUK_INSERTED, - WIIUSE_NUNCHUK_REMOVED, - WIIUSE_CLASSIC_CTRL_INSERTED, - WIIUSE_CLASSIC_CTRL_REMOVED, - WIIUSE_GUITAR_HERO_3_CTRL_INSERTED, - WIIUSE_GUITAR_HERO_3_CTRL_REMOVED -} WIIUSE_EVENT_TYPE; - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ - #endif - - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ - - WCONST int flags; /**< options flag */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int accel_threshold; /**< threshold for accel to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */ - WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef _WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) -#else - #define WIIUSE_EXPORT_DECL - #define WIIUSE_IMPORT_DECL -#endif - -#ifdef WIIUSE_COMPILE_LIB - #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL -#else - #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -WIIUSE_EXPORT extern const char* wiiuse_version(); - -WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds); -WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len); -WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm); -WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid); -WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable); -WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha); -WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); -WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); - -/* connect.c */ -WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); -WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); - -/* events.c */ -WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); - -/* ir.c */ -WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); -WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos); -WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect); -WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level); - -/* nunchuk.c */ -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold); - - -#ifdef __cplusplus -} -#endif - - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/WiiUseJC_0.12/wiiusej_WiiUseApi.c b/WiiUseJC_0.12/wiiusej_WiiUseApi.c deleted file mode 100644 index 0a33786..0000000 --- a/WiiUseJC_0.12/wiiusej_WiiUseApi.c +++ /dev/null @@ -1,583 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -#ifndef WIN32 -#include -#else - -#endif - -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" -/* - * These are some identifiers for wiimotes - * - * See below in main() for what they are used for. - */ -#define WIIMOTE_STATE_RUMBLE 0x0010 -#define WIIMOTE_STATE_CONNECTED 0x0008 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) -#define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \ - do { \ - if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ - else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ - else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ - else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ - else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ - else *lvl = 0; \ - } while (0) - -/********************* VARIABLES DECLARATIONS *****************************/ - -/* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. - */ -static wiimote** wiimotes; -static int nbMaxWiimotes; - -/****************** GENERAL FUNCTIONS DEFINITIONS *************************/ - -/** - * Connect to a wiimote or wiimotes once an address is known. - * @param nbWiimotes The number of wiimotes. - * @return The number of wiimotes that successfully connected. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect -(JNIEnv *env, jobject obj, jint nbWiimotes) { - return wiiuse_connect(wiimotes, nbWiimotes); -} - -/** - * Find a wiimote or wiimotes. - * @param nbMaxWiimotes The number of wiimotes. - * @param timeout The number of seconds before the search times out. - * @return The number of wiimotes found. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find -(JNIEnv *env, jobject obj, jint nbMaxWiimotes, jint timeout) { - return wiiuse_find(wiimotes, nbMaxWiimotes, timeout); -} - -/** - * Initialize an array of wiimote structures (for the C side of the library). - * @param nbPossibleWiimotes size of the array. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init -(JNIEnv *env, jobject obj, jint nbPossibleWiimotes) { - wiimotes = wiiuse_init(nbPossibleWiimotes); - nbMaxWiimotes = nbPossibleWiimotes; -} - -/** - * Close connection to the wiimote with the given id. - * - * @param id the id of the wiimote to disconnect.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection -(JNIEnv *env, jobject obj, jint id) { - wiiuse_disconnect(wiimotes[id]); -} - -/** - * Get unique id of a wiimote in the wiimotes array. - * Please make sure you call an existing index with a - * wiimote initialized at this index, - * other wise you'll get a wrong value. - * @param index index of the wiimote in the wiimotes array. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId -(JNIEnv *env, jobject obj, jint index) { - return wiimotes[index]->unid; -} - -/** - * Shutdown api. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp -(JNIEnv *env, jobject obj) { - wiiuse_cleanup(wiimotes, nbMaxWiimotes); -} - -/** - * Activate rumble for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble -(JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); -} - -/** - * Deactivate rumble for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble -(JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); -} - -/** - * Activate IR TRacking for the wiimote with the given id. - * @param id the id of the wiimote. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); -} - -/** - * Deactivate IR TRacking for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); -} - -/** - * Activate Motion Sensing for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 1); -} - -/** - * Deactivate Motion Sensing for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0); -} - -/** - * Set wiimote leds status. - * @param id the id of the wiimote concerned - * @param led1 status of led1: True=ON, False=OFF - * @param led2 status of led2: True=ON, False=OFF - * @param led3 status of led3: True=ON, False=OFF - * @param led4 status of led4: True=ON, False=OFF - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds -(JNIEnv *env, jobject obj, jint id, jboolean led1, jboolean led2, jboolean led3, jboolean led4) { - int leds = 0; - - if (led1) leds |= WIIMOTE_LED_1; - if (led2) leds |= WIIMOTE_LED_2; - if (led3) leds |= WIIMOTE_LED_3; - if (led4) leds |= WIIMOTE_LED_4; - - wiiuse_set_leds(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), leds); -} - -/** - * Set how many degrees an angle must change to generate an event. - * @param id id of the wiimote concerned - * @param thresh minimum angle detected by an event - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold -(JNIEnv *env, jobject obj, jint id, jfloat thresh) { - wiiuse_set_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); -} - -/** - * Set how much acceleration must change to generate an event. - * @param id id of the wiimote concerned - * @param val minimum value detected by an event - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold -(JNIEnv *env, jobject obj, jint id, jint val) { - wiiuse_set_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); -} - -/** - * Set alpha smoothing parameter for the given id. - * @param id id of the wiimote concerned - * @param value alpha smoothing value - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing -(JNIEnv *env, jobject obj, jint id, jfloat val) { - wiiuse_set_smooth_alpha(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); -} - -/** - * Try to resync with the wiimote by starting a new handshake. - * @param id id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync -(JNIEnv *env, jobject obj, jint id) { - wiiuse_resync(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); -} - -/** - * Make the the accelerometers give smoother results. - * This is set by default. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_SMOOTHING, 0); -} - -/** - * Make the the accelerometers give raw results. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_SMOOTHING); -} - -/** - * Make the wiimote generate an event each time we poll. - * Not set by default. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_CONTINUOUS, 0); -} - -/** - * Make the wiimote generate an event only when there is one. - * (default behavior) - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), 0, WIIUSE_CONTINUOUS); -} - -/** - * Notify wiiuse that your screen has an aspect ratio of 4/3. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); -} - -/** - * Notify wiiuse that your screen has an aspect ratio of 16/9. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_aspect_ratio(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_ASPECT_4_3); -} - -/** - * Notify wiiuse that the sensor bar is above your screen. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_ABOVE); -} - -/** - * Notify wiiuse that the sensor bar is below your screen. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir_position(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), WIIUSE_IR_BELOW); -} - -/** - * Set virtual screen resolution. It is used to automatically - * compute the position of a cursor on this virtual screen - * using the sensor bar. These results come in the IREvent. - * @param id the id of the wiimote concerned - * @param x x resolution. - * @param y y resolution. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution -(JNIEnv *env, jobject obj, jint id, jint x, jint y) { - wiiuse_set_ir_vres(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), x, y); -} - -/** - * Get status from the wiimotes and send it through call backs. - * - * @param id the id of the wiimote. Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus -(JNIEnv *env, jobject obj, jint id) { - wiiuse_status(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); -} - -/** - * Set the normal and expansion handshake timeouts. - * - * @param id - * the id of the wiimote concerned. - * @param normalTimeout - * The timeout in milliseconds for a normal read. - * @param expansionTimeout - * The timeout in millisecondsd to wait for an expansion - * handshake. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout -(JNIEnv *env, jobject obj, jint id, jshort normalTimeout, jshort expansionTimeout) { - wiiuse_set_timeout(wiimotes, nbMaxWiimotes, 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. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity -(JNIEnv *env, jobject obj, jint id, jint level) { - wiiuse_set_ir_sensitivity(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), level); -} - -/** - * Set how many degrees an angle must change to generate an event for the nunchuk. - * @param id id of the wiimote concerned - * @param thresh minimum angle detected by an event - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold -(JNIEnv *env, jobject obj, jint id, jfloat thresh) { - wiiuse_set_nunchuk_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); -} - -/** - * Set how much acceleration must change to generate an event for the nunchuk. - * @param id id of the wiimote concerned - * @param val minimum value detected by an event - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold -(JNIEnv *env, jobject obj, jint id, jint val) { - wiiuse_set_nunchuk_accel_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), val); -} - -/** - * Force the bluetooth stack type.(useful only for windows) - * - * @param bluetoothStackType - * must be WiiUseApi.WIIUSE_STACK_UNKNOWN or WiiUseApi.WIIUSE_STACK_MS or - * WiiUseApi.WIIUSE_STACK_BLUESOLEIL. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack -(JNIEnv *env, jobject obj, jint bluetoothStackType) { - if (bluetoothStackType == 0) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_UNKNOWN); - } else if (bluetoothStackType == 1) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_MS); - } else if (bluetoothStackType == 2) { - wiiuse_set_bluetooth_stack(wiimotes, nbMaxWiimotes, WIIUSE_STACK_BLUESOLEIL); - } -} - -/** - * Get status and values from the wiimotes and send it through callbacks. - * @param wim the wiimote object to fill with the datas. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll -(JNIEnv *env, jobject obj, jobject gath) { - - /* Variables Declarations */ - int i; - 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); - - mid = (*env)->GetMethodID(env, cls, "prepareIRevent", - "(IIFIIIIIISSSF)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->ir.x, wiimotes[i]->ir.y, wiimotes[i]->ir.z, - wiimotes[i]->ir.ax, wiimotes[i]->ir.ay, - wiimotes[i]->ir.vres[0], wiimotes[i]->ir.vres[1], - wiimotes[i]->ir.offset[0], wiimotes[i]->ir.offset[1], - wiimotes[i]->ir.pos, wiimotes[i]->ir.aspect, - a , wiimotes[i]->ir.distance); - - mid = (*env)->GetMethodID(env, cls, "addIRPointToPreparedWiiMoteEvent", - "(IISSS)V"); - if (mid == 0) { - return; - } - /* go through each of the 4 possible IR sources */ - for (a=0; a < 4; a++) { - /* check if the source is visible */ - if (wiimotes[i]->ir.dot[a].visible) { - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->ir.dot[a].x, wiimotes[i]->ir.dot[a].y, - wiimotes[i]->ir.dot[a].rx, wiimotes[i]->ir.dot[a].ry, - wiimotes[i]->ir.dot[a].size); - } - } - } - - /* Motion Sensing */ - if (WIIUSE_USING_ACC(wiimotes[i])) { - /* 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 to 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); - } - } - - /* add generic event to java object used to gather events in c environment */ - mid = (*env)->GetMethodID(env, cls, "addWiimoteEvent", - "()V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid); - break; - - case WIIUSE_DISCONNECT: - /* the wiimote disconnected */ - mid = (*env)->GetMethodID(env, cls, "addDisconnectionEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; - - case WIIUSE_UNEXPECTED_DISCONNECT: - /* the 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_NUNCHUK_INSERTED: - /* the wiimote disconnected */ - 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 wiimote disconnected */ - mid = (*env)->GetMethodID(env, cls, "addNunchukRemovedEvent", "(I)V"); - if (mid == 0) { - return; - } - (*env)->CallVoidMethod(env, gath, mid, wiimotes[i]->unid); - break; - - case WIIUSE_STATUS: - /* a status event occured */ - mid = (*env)->GetMethodID(env, cls, "addStatusEvent", "(IZFSZIZZZZ)V"); - if (mid == 0) { - return; - } - /* LEDS */ - if (WIIUSE_IS_LED_SET(wiimotes[i], 1)) leds += 1; - if (WIIUSE_IS_LED_SET(wiimotes[i], 2)) leds += 2; - if (WIIUSE_IS_LED_SET(wiimotes[i], 3)) leds += 4; - if (WIIUSE_IS_LED_SET(wiimotes[i], 4)) leds += 8; - - (*env)->CallVoidMethod(env, gath, mid, - wiimotes[i]->unid, WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_CONNECTED), - wiimotes[i]->battery_level, leds, WIIUSE_USING_SPEAKER(wiimotes[i]), - wiimotes[i]->exp.type,WIIMOTE_IS_SET(wiimotes[i], WIIMOTE_STATE_RUMBLE), - WIIMOTE_IS_FLAG_SET(wiimotes[i],WIIUSE_CONTINUOUS), - WIIUSE_USING_IR(wiimotes[i]),WIIUSE_USING_ACC(wiimotes[i])); - break; - - default: - break; - } - } - } -} diff --git a/WiiUseJC_0.12/wiiusej_WiiUseApi.def b/WiiUseJC_0.12/wiiusej_WiiUseApi.def deleted file mode 100644 index e7aebd3..0000000 --- a/WiiUseJC_0.12/wiiusej_WiiUseApi.def +++ /dev/null @@ -1,34 +0,0 @@ -EXPORTS -Java_wiiusej_WiiUseApi_connect -Java_wiiusej_WiiUseApi_find -Java_wiiusej_WiiUseApi_init -Java_wiiusej_WiiUseApi_closeConnection -Java_wiiusej_WiiUseApi_getUnId -Java_wiiusej_WiiUseApi_cleanUp -Java_wiiusej_WiiUseApi_activateRumble -Java_wiiusej_WiiUseApi_deactivateRumble -Java_wiiusej_WiiUseApi_activateIRTracking -Java_wiiusej_WiiUseApi_deactivateIRTracking -Java_wiiusej_WiiUseApi_activateMotionSensing -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_setLeds -Java_wiiusej_WiiUseApi_setOrientThreshold -Java_wiiusej_WiiUseApi_setAccelThreshold -Java_wiiusej_WiiUseApi_setAlphaSmoothing -Java_wiiusej_WiiUseApi_reSync -Java_wiiusej_WiiUseApi_activateSmoothing -Java_wiiusej_WiiUseApi_deactivateSmoothing -Java_wiiusej_WiiUseApi_activateContinuous -Java_wiiusej_WiiUseApi_deactivateContinuous -Java_wiiusej_WiiUseApi_setScreenRatio43 -Java_wiiusej_WiiUseApi_setScreenRatio169 -Java_wiiusej_WiiUseApi_setSensorBarAboveScreen -Java_wiiusej_WiiUseApi_setSensorBarBelowScreen -Java_wiiusej_WiiUseApi_setVirtualScreenResolution -Java_wiiusej_WiiUseApi_getStatus -Java_wiiusej_WiiUseApi_setTimeout -Java_wiiusej_WiiUseApi_setIrSensitivity -Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold -Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold -Java_wiiusej_WiiUseApi_windowsSetBluetoothStack -Java_wiiusej_WiiUseApi_specialPoll diff --git a/WiiUseJC_0.12/wiiusej_WiiUseApi.h b/WiiUseJC_0.12/wiiusej_WiiUseApi.h deleted file mode 100644 index 3680631..0000000 --- a/WiiUseJC_0.12/wiiusej_WiiUseApi.h +++ /dev/null @@ -1,277 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class wiiusej_WiiUseApi */ - -#ifndef _Included_wiiusej_WiiUseApi -#define _Included_wiiusej_WiiUseApi -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: wiiusej_WiiUseApi - * Method: connect - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_connect - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: find - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_find - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: init - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_init - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: closeConnection - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getUnId - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_getUnId - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: cleanUp - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_cleanUp - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setLeds - * Signature: (IZZZZ)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds - (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: setOrientThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAccelThreshold - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAccelThreshold - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setAlphaSmoothing - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setAlphaSmoothing - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: reSync - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_reSync - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio43 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio43 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setScreenRatio169 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setScreenRatio169 - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarAboveScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarAboveScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setSensorBarBelowScreen - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSensorBarBelowScreen - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setVirtualScreenResolution - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setVirtualScreenResolution - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getStatus - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setTimeout - * Signature: (ISS)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setTimeout - (JNIEnv *, jobject, jint, jshort, jshort); - -/* - * Class: wiiusej_WiiUseApi - * Method: setIrSensitivity - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setIrSensitivity - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setNunchukOrientationThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: setNunchukAccelerationThreshold - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukAccelerationThreshold - (JNIEnv *, jobject, jint, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: windowsSetBluetoothStack - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_windowsSetBluetoothStack - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: specialPoll - * Signature: (Lwiiusej/wiiusejevents/utils/EventsGatherer;)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/WiiUseJ_0.1/.classpath b/WiiUseJ_0.1/.classpath deleted file mode 100644 index d171cd4..0000000 --- a/WiiUseJ_0.1/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/WiiUseJ_0.1/.project b/WiiUseJ_0.1/.project deleted file mode 100644 index 9485f4a..0000000 --- a/WiiUseJ_0.1/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - WiiUseJava - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/WiiUseJ_0.1/README.TXT b/WiiUseJ_0.1/README.TXT deleted file mode 100644 index 268d31d..0000000 --- a/WiiUseJ_0.1/README.TXT +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ - - -WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI. - -WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes. - -Some of the great aspects of this API are : - - * The compatibility which is as large as Wiiuse's API compatibility - - * Cross-platform : Windows and linux (like Wiiuse) - - * Easy to use - - -WiiuseJ is made by Guilhem Duché : guiguito1@hotmail.com. -You can contact me if you need more information. - -Go to : http://wiiusej.googlecode.com/ for further documentations. - - - diff --git a/WiiUseJ_0.1/img/wiimote.png b/WiiUseJ_0.1/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.1/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.1/libWiiuseJ.dll b/WiiUseJ_0.1/libWiiuseJ.dll deleted file mode 100644 index d06e041..0000000 Binary files a/WiiUseJ_0.1/libWiiuseJ.dll and /dev/null differ diff --git a/WiiUseJ_0.1/src/img/wiimote.png b/WiiUseJ_0.1/src/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.1/src/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.1/src/wiiusej/WiiUseApi.java b/WiiUseJ_0.1/src/wiiusej/WiiUseApi.java deleted file mode 100644 index f9be625..0000000 --- a/WiiUseJ_0.1/src/wiiusej/WiiUseApi.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import wiiusej.wiiuseapievents.EventsGatherer; - -/** - * Singleton used to manipulate WiiUse Api. - * @author guiguito - */ -public class WiiUseApi { - - static { - System.loadLibrary("libWiiuseJ"); - } - - private static WiiUseApi instance = new WiiUseApi(); - - /** - * Get the only instance of WiiUseApi. - * @return the only instace of WiiUseApi. - */ - static WiiUseApi getInstance(){ - return instance; - } - - /** - * Try to connect to 2 wiimotes. Make them rumble to show they are - * connected. - * @param nb number of wiimotes to connect - * @return 0 if there is an error otherwise it returns the number of - * wiimotes connected. - */ - native int doConnections(int nb); - - /** - * Close connection to the wiimote with the given id. - * - */ - native void closeConnection(int id); - - /** - * Shutdown Wiiuse API. - */ - native void shutdownApi(); - - /** - * Activate rumble on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateRumble(int id); - - /** - * Deactivate rumble on the wiimote with the given id. - * - * @param id the id of the wiimote. - */ - native void deactivateRumble(int id); - - /** - * Activate IR Tracking on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateIRTracking(int id); - - /** - * Deactivate IR Tracking on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void deactivateIRTracking(int id); - - /** - * Activate motion sensing on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateMotionSensing(int id); - - /** - * Deactivate motion sensing on the wiimote with the given id. - * @param id the id of the wiimote. - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - native void activateSmoothing(int id); - - /** - * Make the the accelerometers give raw results. - * @param id the id of the wiimote concerned - */ - 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 - */ - native void activateContinuous(int id); - - /** - * Make the wiimote generate an event only when there is one. - * @param id the id of the wiimote concerned - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - native void getStatus(int id); - - /** - * 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/WiiUseJ_0.1/src/wiiusej/WiiUseApiManager.java b/WiiUseJ_0.1/src/wiiusej/WiiUseApiManager.java deleted file mode 100644 index 647fbd8..0000000 --- a/WiiUseJ_0.1/src/wiiusej/WiiUseApiManager.java +++ /dev/null @@ -1,567 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.EventsGatherer; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapirequest.FloatValueRequest; -import wiiusej.wiiuseapirequest.IntValueRequest; -import wiiusej.wiiuseapirequest.LedsRequest; -import wiiusej.wiiuseapirequest.TwoIntValueRequest; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that manages the use of Wiiuse API. - * - * @author guiguito - */ -public class WiiUseApiManager extends Thread { - - private static WiiUseApiManager instance = new WiiUseApiManager(); - - private final EventListenerList listeners = new EventListenerList(); - - private Wiimote[] wiimotes; - - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - - private int connected = -1; - - private int nbMaxWiimotes = -1; - - private AtomicBoolean running = new AtomicBoolean(false); - - private ConcurrentLinkedQueue requests = new ConcurrentLinkedQueue(); - - 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 - * @return an array with connected wiimotes or NULL. - */ - public synchronized static Wiimote[] getWiimotes(int nb) { - WiiUseApiManager manager = getInstance(); - if (manager.connected < 0) { - int nbWiimotes = manager.connectWiimotes(nb); - manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i = 1; i <= nbWiimotes; i++) { - Wiimote wim = new Wiimote(i, manager); - manager.wiimotes[i - 1] = wim; - manager.addWiiUseApiListener(wim); - } - } - - if (manager.connected == 0) { - return new Wiimote[0]; - } - - if (!manager.isAlive()) - manager.start(); - - return manager.wiimotes; - } - - /** - * Connect wiimote and get the number of wiimotes connected. Supposed to be - * used once. - * - * @param nb - * try to connect nb wiimotes - * @return 0 if nothing connected or the number of wiimotes connected. - */ - private int connectWiimotes(int nb) { - nbMaxWiimotes = nb; - if (connected < 0) { - connected = wiiuse.doConnections(nb); - 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. - */ - public void closeConnection(int id) { - removeWiiUseApiListener(wiimotes[id - 1]); - wiimotes[id - 1] = null; - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST)); - // System.out.println("Wiimote " + id + " disconnected !"); - } - - /** - * Get the number of wiimotes connected. - * - * @return the number of wiimotes connected. - */ - public int getNbConnectedWiimotes() { - return connected; - } - - /** - * Stop thread and shutdown wiiuse Api. - */ - public void shutdown() { - if (connected > 0) { - for (Wiimote wim : wiimotes) { - if (wim != null) - wim.disconnect(); - } - } - running.set(false); - wiiuse.shutdownApi(); - } - - /** - * Activate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Deactivate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Activate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Deactivate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Activate motion sensing for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Deactivate motion sensing for the wiimoter with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Activate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Deactivate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Activate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * Deactivate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote - */ - public void deactivateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * 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 - */ - public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) { - requests.add(new LedsRequest(id, WiiUseApiRequest.WIIUSE_LEDS_REQUEST, - l1, l2, l3, l4)); - } - - /** - * Set the orientation threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(int id, float th) { - requests.add(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST, th)); - } - - /** - * Set the acceleration threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAccelerationThreshold(int id, int th) { - requests.add(new IntValueRequest(id, - WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th)); - } - - /** - * Set alpha smoothing for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAlphaSmoothing(int id, float th) { - requests.add(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th)); - } - - /** - * Try to resync with the wiimote by starting a new handshake. - * - * @param id - * id of the wiimote - */ - public void reSync(int id) { - requests.add(new WiiUseApiRequest(id, WiiUseApiRequest.WIIUSE_RESYNC)); - } - - /** - * Set screen aspect ratio to 4/3 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio43(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3)); - } - - /** - * Set screen aspect ratio to 16/9 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio169(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9)); - } - - /** - * Set the sensor bar to be above the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarAboveScreen(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE)); - } - - /** - * Set the sensor bar to be below the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarBelowScreen(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW)); - } - - /** - * 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 - */ - public void setVirtualResolution(int id, int x, int y) { - requests.add(new TwoIntValueRequest(id, - WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION, x, y)); - } - - /** - * Get Status for the wiimote for the given id. - * - * @param id - * id of the wiimote - */ - public void getStatus(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_STATUS_REQUEST)); - } - - @Override - public void run() { - - if (connected > 0) { - running.set(true); - - EventsGatherer gather = new EventsGatherer(nbMaxWiimotes); - - // Start polling and tell the observers when there Wiimote events - while (running.get() && connected > 0) { - - /* 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(); - - /* deal with request done to wiiuse API */ - WiiUseApiRequest req = requests.poll(); - if (req != null) {// there is a request for the wiiuse api - int id = req.getId(); - if (req.getRequestType() == WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST) { - /* Close connections requests */ - wiiuse.closeConnection(id); - - connected--; - if (connected == 0) {// stop this thread if there is - // no more wiimotes connected. - // System.out.println("No more wiimotes connected - // !!!"); - shutdown(); - } - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) { - /* Status requests */ - wiiuse.getStatus(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST) { - /* Activate Rumble requests */ - wiiuse.activateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST) { - /* Deactivate Rumble requests */ - wiiuse.deactivateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST) { - /* Activate IR Tracking requests */ - wiiuse.activateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST) { - /* Deactivate IR Tracking requests */ - wiiuse.deactivateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST) { - /* Activate Motion sensing requests */ - wiiuse.activateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST) { - /* Deactivate Motion sensing requests */ - wiiuse.deactivateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_LEDS_REQUEST) { - /* leds requests */ - LedsRequest reqLed = (LedsRequest) req; - wiiuse.setLeds(id, reqLed.isLed1(), reqLed.isLed2(), - reqLed.isLed3(), reqLed.isLed4()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST) { - /* Activate smoothing requests */ - wiiuse.activateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST) { - /* Deactivate smoothing requests */ - wiiuse.deactivateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST) { - /* Activate continuous requests */ - wiiuse.activateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST) { - /* Deactivate continuous requests */ - wiiuse.deactivateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST) { - /* set orientation threshold request */ - wiiuse.setOrientThreshold(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) { - /* set acceleration threshold request */ - wiiuse.setAccelThreshold(req.getId(), - ((IntValueRequest) req).getIntValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) { - /* set alpha smoothing request */ - wiiuse.setAlphaSmoothing(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) { - /* set resync request */ - wiiuse.reSync(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3) { - /* set screen aspect ratio to 4/3 */ - wiiuse.setScreenRatio43(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9) { - /* set screen aspect ratio to 16/9 */ - wiiuse.setScreenRatio169(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarAboveScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarBelowScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION) { - /* set virtual resolution */ - wiiuse.setVirtualScreenResolution(req.getId(), - ((TwoIntValueRequest) req).getIntValue(), - ((TwoIntValueRequest) req).getSecondIntValue()); - } else { - System.out.println("Bad request to Wiiuse API !!!!!"); - } - } - } - } else { - if (connected <= 0) { - System.out.println("No wiimotes connected !"); - } - } - - } - - /** - * Add WiiUseApiListener to the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void addWiiUseApiListener(WiiUseApiListener listener) { - listeners.add(WiiUseApiListener.class, listener); - } - - /** - * Remove WiiUseApiListener from the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void removeWiiUseApiListener(WiiUseApiListener listener) { - listeners.remove(WiiUseApiListener.class, listener); - } - - /** - * Get the list of WiiUseApiListeners. - * - * @return the list of WiiUseApiListeners. - */ - public WiiUseApiListener[] getWiiUseApiListeners() { - return listeners.getListeners(WiiUseApiListener.class); - } - - /** - * Notify WiiUseApiListeners that an event occured. - * - * @param evt - * WiimoteEvent occured - */ - private void notifyWiiUseApiListener(WiiUseApiEvent evt) { - for (WiiUseApiListener listener : getWiiUseApiListeners()) { - listener.onWiiUseApiEvent(evt); - } - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/Wiimote.java b/WiiUseJ_0.1/src/wiiusej/Wiimote.java deleted file mode 100644 index f04e66c..0000000 --- a/WiiUseJ_0.1/src/wiiusej/Wiimote.java +++ /dev/null @@ -1,323 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapievents.WiimoteListener; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that represents a wiimote. - * You can register as an observer of this wiimote to listen events from it. - * You manage it. - * @author guiguito - */ -public class Wiimote implements WiiUseApiListener { - - private int id = -1;//wiimote id - - private EventListenerList listeners = new EventListenerList(); - - 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; - } - - /** - * Disconnect this wiimote. - */ - public void disconnect(){ - deactivateIRTRacking(); - deactivateMotionSensing(); - deactivateRumble(); - manager.closeConnection(id); - } - - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } - - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } - - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } - - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } - - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } - - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } - - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } - - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } - - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(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 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 . - * @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 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 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 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); - } - - /** - * 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); - } - - /** - * 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((GenericEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED - ||e.getEventType() == 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){ - notifyStatusEventListeners((StatusEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT){ - notifyDisconnectionEventListeners((DisconnectionEvent)e); - } - } - } - - /** - * 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); - } - - /** - * 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 WiimoteEvent occured - */ - private void notifyWiiMoteEventListeners(GenericEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onButtonsEvent(evt.getButtonsEvent()); - if (evt.isThereIrEvent()){ - listener.onIrEvent(evt.getIREvent()); - } - if (evt.isThereMotionSensingEvent()){ - listener.onMotionSensingEvent(evt.getMotionSensingEvent()); - } - } - } - - /** - * 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 notifyDisconnectionEventListeners(DisconnectionEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onDisconnectionEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : "+id; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/test/CloseGuiTestCleanly.java b/WiiUseJ_0.1/src/wiiusej/test/CloseGuiTestCleanly.java deleted file mode 100644 index ae136bf..0000000 --- a/WiiUseJ_0.1/src/wiiusej/test/CloseGuiTestCleanly.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * This class is used to close wiiusej cleanly. - * @author guiguito - */ -public class CloseGuiTestCleanly implements WindowListener{ - - Wiimote wiimote; - - - public CloseGuiTestCleanly(Wiimote wim) { - wiimote = wim; - } - - public void windowOpened(WindowEvent e) { - //nothing - } - - public void windowClosing(WindowEvent e) { - WiiUseApiManager.getInstance().shutdown(); - } - - public void windowClosed(WindowEvent e) { - //nothing - } - - public void windowIconified(WindowEvent e) { - //nothing - } - - public void windowDeiconified(WindowEvent e) { - //nothing - } - - public void windowActivated(WindowEvent e) { - //nothing - } - - public void windowDeactivated(WindowEvent e) { - //nothing - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/test/Main.java b/WiiUseJ_0.1/src/wiiusej/test/Main.java deleted file mode 100644 index 0f873bb..0000000 --- a/WiiUseJ_0.1/src/wiiusej/test/Main.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * Main Class to launch WiiuseJ GUI Test. - * @author guiguito - */ -public class Main { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1); - if (wiimotes.length>0){ - WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]); - gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); - gui.setVisible(true); - } - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/test/Tests.java b/WiiUseJ_0.1/src/wiiusej/test/Tests.java deleted file mode 100644 index f9e20f9..0000000 --- a/WiiUseJ_0.1/src/wiiusej/test/Tests.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.values.IRSource; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This class used to test WiiuseJ. - * - * @author guiguito - */ -public class Tests implements WiimoteListener { - - 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 Wiimote wiimote; - - int dump = DISPLAY_EACH_VALUE; - - public Tests(Wiimote wim) { - wiimote = wim; - wiimote.addWiiMoteEventListeners(this); - try { - robot = new Robot(); - } catch (AWTException e) { - e.printStackTrace(); - } - } - - private static int nb = 0; - - public void onButtonsEvent(ButtonsEvent 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 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 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 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 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 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(); - } - - /* 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 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(); - } - - } 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(); - } - - /* 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); - } - - /* 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(); - } - } - - } - - 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); - } - } - - public void onMotionSensingEvent(MotionSensingEvent e) { - /* display motion sensing */ - 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 !!"); - } - - /** - * @param args - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(4); - if (wiimotes.length > 0) { - System.out.println(wiimotes[0]); - Tests tests = 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); - - } -} diff --git a/WiiUseJ_0.1/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ_0.1/src/wiiusej/test/WiiuseJGuiTest.java deleted file mode 100644 index 8bac8ae..0000000 --- a/WiiUseJ_0.1/src/wiiusej/test/WiiuseJGuiTest.java +++ /dev/null @@ -1,836 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; -import java.util.logging.Level; -import java.util.logging.Logger; -import wiiusej.utils.IRPanel; -import wiiusej.Wiimote; -import wiiusej.utils.AccelerationPanel; -import wiiusej.utils.GForcePanel; -import wiiusej.utils.ButtonsEventPanel; -import wiiusej.utils.OrientationPanel; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * Gui class to test WiiuseJ. - * @author guiguito - */ -public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListener { - - private Wiimote wiimote; - private Robot robot = null; - private boolean statusMotionRequested = false; - private boolean statusIRRequested = false; - - /** Creates new form WiiuseJGuiTest */ - public WiiuseJGuiTest(Wiimote wiimote) { - initComponents(); - this.wiimote = wiimote; - wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel); - wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); - wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel); - wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel); - wiimote.addWiiMoteEventListeners(this); - wiimote.deactivateContinuous(); - wiimote.deactivateSmoothing(); - wiimote.setScreenAspectRatio169(); - wiimote.setSensorBarBelowScreen(); - getStatusButtonMousePressed(null); - this.addWindowListener(new CloseGuiTestCleanly(wiimote)); - } - - public void onButtonsEvent(ButtonsEvent arg0) { - if (robot != null) { - if (arg0.isButtonAPressed()) { - robot.mousePress(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBPressed()) { - robot.mousePress(InputEvent.BUTTON2_MASK); - - } - if (arg0.isButtonOnePressed()) { - robot.mousePress(InputEvent.BUTTON3_MASK); - - } - if (arg0.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_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.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 onMotionSensingEvent(MotionSensingEvent arg0) { - if (statusMotionRequested){//Status requested - accelerationThresholdTextField.setText(""+arg0.getAccelerationThreshold()); - orientationThresholdTextField.setText(""+arg0.getOrientationThreshold()); - alphaSmoothingTextField.setText(""+arg0.getAlphaSmoothing()); - statusMotionRequested = false; - } - } - - public void onStatusEvent(StatusEvent arg0) { - messageText.setText("Status received !"); - batteryLevelText.setText(arg0.getBatteryLevel() + " %"); - led1Button.setEnabled(arg0.isLed1Set()); - led2Button.setEnabled(arg0.isLed2Set()); - led3Button.setEnabled(arg0.isLed3Set()); - led4Button.setEnabled(arg0.isLed4Set()); - //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 !"); - } - - /** 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() { - - leftPanel = new javax.swing.JPanel(); - irViewPanel = new IRPanel(); - jTabbedPane1 = new javax.swing.JTabbedPane(); - motionSensingPanel = new OrientationPanel(); - gForcePanel = new wiiusej.utils.GForcePanel(); - accelerationPanel = new AccelerationPanel(); - rightPanel = new javax.swing.JPanel(); - fixedWiimotePanel = new javax.swing.JPanel(); - buttonsPanel = new ButtonsEventPanel(); - controlsPanel = new javax.swing.JPanel(); - activateRumblePanel = new javax.swing.JPanel(); - toggleRumbleButton = new javax.swing.JButton(); - deactivateRumblePanel = new javax.swing.JPanel(); - toggleIRTrackingButton = new javax.swing.JButton(); - activateIRtrackingPanel = new javax.swing.JPanel(); - toggleMotionSensingTrackingButton = new javax.swing.JButton(); - deactivateIRTrackingPanel = new javax.swing.JPanel(); - toggleSmoothingButton = new javax.swing.JButton(); - activateMotionSensingTrackingPanel = new javax.swing.JPanel(); - toggleContinuousButton = new javax.swing.JButton(); - deactivateMotionSensingTrackingPanel = new javax.swing.JPanel(); - led1Button = new javax.swing.JButton(); - led2Button = new javax.swing.JButton(); - led3Button = new javax.swing.JButton(); - led4Button = new javax.swing.JButton(); - setLedsButton = new javax.swing.JButton(); - activateSmoothingPanel = new javax.swing.JPanel(); - alphaSmoothingTextField = new javax.swing.JTextField(); - alphaSmoothingButton = new javax.swing.JButton(); - deactivateSmoothingPanel = new javax.swing.JPanel(); - orientationThresholdTextField = new javax.swing.JTextField(); - orientationThresholdButton = new javax.swing.JButton(); - activateContinuousPanel = new javax.swing.JPanel(); - accelerationThresholdTextField = new javax.swing.JTextField(); - accelerationThresholdButton = new javax.swing.JButton(); - deactivateContinuousPanel = new javax.swing.JPanel(); - getStatusButton = new javax.swing.JButton(); - batteryText = new javax.swing.JLabel(); - batteryLevelText = new javax.swing.JLabel(); - ledsPanel = new javax.swing.JPanel(); - toggleSensorBarPositionButton = new javax.swing.JButton(); - alphaSmoothingPanel = new javax.swing.JPanel(); - toggleScreenAspectRatioButton = new javax.swing.JButton(); - orientationThresholdPanel = new javax.swing.JPanel(); - xLabel = new javax.swing.JLabel(); - xResolutionTextField = new javax.swing.JTextField(); - yLabel = new javax.swing.JLabel(); - yResolutionTextField = new javax.swing.JTextField(); - setVirtualResolutionButton = new javax.swing.JButton(); - accelerationThresholdPanel = new javax.swing.JPanel(); - mouseIRControlButton = new javax.swing.JButton(); - batteryPanel = new javax.swing.JPanel(); - expansionText = new javax.swing.JLabel(); - messagesPanel = new javax.swing.JPanel(); - messageLabelText = new javax.swing.JLabel(); - messageText = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("WiiuseJ Test GUI"); - setName("WiiuseJ Test GUI"); // NOI18N - - leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - irViewPanel.setBackground(new java.awt.Color(0, 0, 0)); - irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 2, true), "IR View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, 51))); - - javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(irViewPanel); - irViewPanel.setLayout(irViewPanelLayout); - irViewPanelLayout.setHorizontalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 272, Short.MAX_VALUE) - ); - irViewPanelLayout.setVerticalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 299, Short.MAX_VALUE) - ); - - javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(motionSensingPanel); - motionSensingPanel.setLayout(motionSensingPanelLayout); - motionSensingPanelLayout.setHorizontalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - motionSensingPanelLayout.setVerticalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Orientation", motionSensingPanel); - - javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel); - gForcePanel.setLayout(gForcePanelLayout); - gForcePanelLayout.setHorizontalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - gForcePanelLayout.setVerticalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("GForce", gForcePanel); - - javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(accelerationPanel); - accelerationPanel.setLayout(accelerationPanelLayout); - accelerationPanelLayout.setHorizontalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - accelerationPanelLayout.setVerticalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Raw Acceleration", accelerationPanel); - - javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel); - leftPanel.setLayout(leftPanelLayout); - leftPanelLayout.setHorizontalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE) - ); - leftPanelLayout.setVerticalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup() - .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(irViewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation"); - - rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.LINE_AXIS)); - - fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767)); - fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setPreferredSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setRequestFocusEnabled(false); - fixedWiimotePanel.setLayout(null); - - buttonsPanel.setMaximumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setMinimumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setOpaque(false); - buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484)); - - javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(buttonsPanel); - buttonsPanel.setLayout(buttonsPanelLayout); - buttonsPanelLayout.setHorizontalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 120, Short.MAX_VALUE) - ); - buttonsPanelLayout.setVerticalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 484, Short.MAX_VALUE) - ); - - fixedWiimotePanel.add(buttonsPanel); - buttonsPanel.setBounds(0, 0, 120, 484); - - rightPanel.add(fixedWiimotePanel); - - controlsPanel.setMinimumSize(new java.awt.Dimension(100, 264)); - controlsPanel.setPreferredSize(new java.awt.Dimension(190, 264)); - controlsPanel.setLayout(new java.awt.GridLayout(16, 1)); - - toggleRumbleButton.setText("Activate Rumble"); - toggleRumbleButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleRumbleButtonMousePressed(evt); - } - }); - activateRumblePanel.add(toggleRumbleButton); - - controlsPanel.add(activateRumblePanel); - - toggleIRTrackingButton.setText("Activate IR Tracking"); - toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleIRTrackingButtonMousePressed(evt); - } - }); - deactivateRumblePanel.add(toggleIRTrackingButton); - - controlsPanel.add(deactivateRumblePanel); - - toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking"); - toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleMotionSensingTrackingButtonMousePressed(evt); - } - }); - activateIRtrackingPanel.add(toggleMotionSensingTrackingButton); - - controlsPanel.add(activateIRtrackingPanel); - - toggleSmoothingButton.setText("Activate Smoothing"); - toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSmoothingButtonMousePressed(evt); - } - }); - deactivateIRTrackingPanel.add(toggleSmoothingButton); - - controlsPanel.add(deactivateIRTrackingPanel); - - toggleContinuousButton.setText("Activate Continuous"); - toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleContinuousButtonMousePressed(evt); - } - }); - activateMotionSensingTrackingPanel.add(toggleContinuousButton); - - controlsPanel.add(activateMotionSensingTrackingPanel); - - led1Button.setText("Led1"); - led1Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led1ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led1Button); - - led2Button.setText("Led2"); - led2Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led2ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led2Button); - - led3Button.setText("Led3"); - led3Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led3ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led3Button); - - led4Button.setText("Led4"); - led4Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led4ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led4Button); - - setLedsButton.setText("Set leds"); - setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setLedsButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(setLedsButton); - - controlsPanel.add(deactivateMotionSensingTrackingPanel); - - alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateSmoothingPanel.add(alphaSmoothingTextField); - - alphaSmoothingButton.setText("Set alpha smoothing"); - alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - alphaSmoothingButtonMousePressed(evt); - } - }); - activateSmoothingPanel.add(alphaSmoothingButton); - - controlsPanel.add(activateSmoothingPanel); - - orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - deactivateSmoothingPanel.add(orientationThresholdTextField); - - orientationThresholdButton.setText("Set orientation threshold"); - orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - orientationThresholdButtonMousePressed(evt); - } - }); - deactivateSmoothingPanel.add(orientationThresholdButton); - - controlsPanel.add(deactivateSmoothingPanel); - - accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateContinuousPanel.add(accelerationThresholdTextField); - - accelerationThresholdButton.setText("Set acceleration threshold"); - accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - accelerationThresholdButtonMousePressed(evt); - } - }); - activateContinuousPanel.add(accelerationThresholdButton); - - controlsPanel.add(activateContinuousPanel); - - getStatusButton.setText("Get status"); - getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - getStatusButtonMousePressed(evt); - } - }); - deactivateContinuousPanel.add(getStatusButton); - - batteryText.setFont(new java.awt.Font("Tahoma", 0, 14)); - batteryText.setText("Battery level :"); - deactivateContinuousPanel.add(batteryText); - - batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14)); - batteryLevelText.setText(" %"); - deactivateContinuousPanel.add(batteryLevelText); - - controlsPanel.add(deactivateContinuousPanel); - - toggleSensorBarPositionButton.setText("Set sensor bar above"); - toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSensorBarPositionButtonMousePressed(evt); - } - }); - ledsPanel.add(toggleSensorBarPositionButton); - - controlsPanel.add(ledsPanel); - - toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); - toggleScreenAspectRatioButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleScreenAspectRatioButtonMousePressed(evt); - } - }); - alphaSmoothingPanel.add(toggleScreenAspectRatioButton); - - controlsPanel.add(alphaSmoothingPanel); - - xLabel.setText("X"); - orientationThresholdPanel.add(xLabel); - - xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(xResolutionTextField); - - yLabel.setText("Y"); - orientationThresholdPanel.add(yLabel); - - yResolutionTextField.setFocusTraversalPolicyProvider(true); - yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(yResolutionTextField); - - setVirtualResolutionButton.setText("Set virtual resolution"); - setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setVirtualResolutionButtonMousePressed(evt); - } - }); - orientationThresholdPanel.add(setVirtualResolutionButton); - - controlsPanel.add(orientationThresholdPanel); - - mouseIRControlButton.setText("Start infrared mouse control"); - mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - mouseIRControlButtonMousePressed(evt); - } - }); - accelerationThresholdPanel.add(mouseIRControlButton); - - controlsPanel.add(accelerationThresholdPanel); - - expansionText.setText("No expansion connected"); - batteryPanel.add(expansionText); - - controlsPanel.add(batteryPanel); - - messageLabelText.setFont(new java.awt.Font("Tahoma", 0, 14)); - messageLabelText.setText("Message : "); - messagesPanel.add(messageLabelText); - - messageText.setFont(new java.awt.Font("Arial", 0, 14)); - messageText.setText("None"); - messagesPanel.add(messageText); - - controlsPanel.add(messagesPanel); - - rightPanel.add(controlsPanel); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE) - ); - - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - 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 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 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 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 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 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 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 getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_getStatusButtonMousePressed - wiimote.getStatus(); - statusMotionRequested = true; - statusIRRequested = true; - }//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 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 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 - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel accelerationPanel; - private javax.swing.JButton accelerationThresholdButton; - private javax.swing.JPanel accelerationThresholdPanel; - private javax.swing.JTextField accelerationThresholdTextField; - private javax.swing.JPanel activateContinuousPanel; - private javax.swing.JPanel activateIRtrackingPanel; - private javax.swing.JPanel activateMotionSensingTrackingPanel; - private javax.swing.JPanel activateRumblePanel; - private javax.swing.JPanel activateSmoothingPanel; - private javax.swing.JButton alphaSmoothingButton; - private javax.swing.JPanel alphaSmoothingPanel; - private javax.swing.JTextField alphaSmoothingTextField; - private javax.swing.JLabel batteryLevelText; - private javax.swing.JPanel batteryPanel; - private javax.swing.JLabel batteryText; - private javax.swing.JPanel buttonsPanel; - private javax.swing.JPanel controlsPanel; - private javax.swing.JPanel deactivateContinuousPanel; - private javax.swing.JPanel deactivateIRTrackingPanel; - private javax.swing.JPanel deactivateMotionSensingTrackingPanel; - private javax.swing.JPanel deactivateRumblePanel; - private javax.swing.JPanel deactivateSmoothingPanel; - private javax.swing.JLabel expansionText; - private javax.swing.JPanel fixedWiimotePanel; - private javax.swing.JPanel gForcePanel; - private javax.swing.JButton getStatusButton; - private javax.swing.JPanel irViewPanel; - private javax.swing.JTabbedPane jTabbedPane1; - private javax.swing.JButton led1Button; - private javax.swing.JButton led2Button; - private javax.swing.JButton led3Button; - private javax.swing.JButton led4Button; - private javax.swing.JPanel ledsPanel; - private javax.swing.JPanel leftPanel; - private javax.swing.JLabel messageLabelText; - private javax.swing.JLabel messageText; - private javax.swing.JPanel messagesPanel; - private javax.swing.JPanel motionSensingPanel; - private javax.swing.JButton mouseIRControlButton; - private javax.swing.JButton orientationThresholdButton; - private javax.swing.JPanel orientationThresholdPanel; - private javax.swing.JTextField orientationThresholdTextField; - private javax.swing.JPanel rightPanel; - private javax.swing.JButton setLedsButton; - private javax.swing.JButton setVirtualResolutionButton; - private javax.swing.JButton toggleContinuousButton; - private javax.swing.JButton toggleIRTrackingButton; - private javax.swing.JButton toggleMotionSensingTrackingButton; - private javax.swing.JButton toggleRumbleButton; - private javax.swing.JButton toggleScreenAspectRatioButton; - private javax.swing.JButton toggleSensorBarPositionButton; - private javax.swing.JButton toggleSmoothingButton; - private javax.swing.JLabel xLabel; - private javax.swing.JTextField xResolutionTextField; - private javax.swing.JLabel yLabel; - private javax.swing.JTextField yResolutionTextField; - // End of variables declaration//GEN-END:variables -} diff --git a/WiiUseJ_0.1/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ_0.1/src/wiiusej/utils/AccelerationPanel.java deleted file mode 100644 index 0403255..0000000 --- a/WiiUseJ_0.1/src/wiiusej/utils/AccelerationPanel.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.RawAcceleration; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch raw acceleration values from a MotionSensingEvent. - * @author guiguito - */ -public class AccelerationPanel extends javax.swing.JPanel implements 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(); - - /** Creates new form AccelerationPanel */ - public AccelerationPanel() { - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - int yLine = getHeight() - 25; - - g2.setPaint(lineColor); - g2.drawLine(0, yLine, getWidth(), yLine); - - 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; - } - - //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); - } - - /** - * 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(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getRawAcceleration()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.1/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ_0.1/src/wiiusej/utils/ButtonsEventPanel.java deleted file mode 100644 index 2a4a48f..0000000 --- a/WiiUseJ_0.1/src/wiiusej/utils/ButtonsEventPanel.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.Toolkit; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what buttons are pressed. - * It displays the result of last ButtonsEvent. - * @author guiguito - */ -public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener { - - private Image mImage;//image for double buffering - private Image wiimoteImage;//image for double buffering - private ButtonsEvent buttons; - private Color pressedColor = Color.RED; - private Color heldColor = Color.ORANGE; - private Color releasedColor = Color.YELLOW; - private Shape shape; - - /** - * 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); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - 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"); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - //offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw buttons pushed - g2.drawImage(wiimoteImage, 0, 0, this); - g2.setTransform(new AffineTransform()); - - if (buttons != null) { - /* button ONE */ - if (buttons.isButtonOneJustPressed()) { - drawFunction(g2,pressedColor,53,353); - } - if (buttons.isButtonOneHeld()) { - drawFunction(g2,heldColor,53,353); - } - if (buttons.isButtonOneJustReleased()) { - drawFunction(g2, releasedColor, 53, 353); - } - - /* button TWO */ - if (buttons.isButtonTwoJustPressed()) { - drawFunction(g2,pressedColor,53,395); - } - if (buttons.isButtonTwoHeld()) { - drawFunction(g2,heldColor,53,395); - } - if (buttons.isButtonTwoJustReleased()) { - drawFunction(g2,releasedColor,53,395); - } - - /* button A */ - if (buttons.isButtonAJustPressed()) { - drawFunction(g2,pressedColor,53,150); - } - if (buttons.isButtonAHeld()) { - drawFunction(g2,heldColor,53,150); - } - if (buttons.isButtonAJustReleased()) { - drawFunction(g2,releasedColor,53,150); - } - - /* button B */ - if (buttons.isButtonBJustPressed()) { - drawFunction(g2,pressedColor,16,149); - } - if (buttons.isButtonBHeld()) { - drawFunction(g2,heldColor,16,149); - } - if (buttons.isButtonBJustReleased()) { - drawFunction(g2,releasedColor,16,149); - } - - /* button LEFT */ - if (buttons.isButtonLeftJustPressed()) { - drawFunction(g2,pressedColor,33,77); - } - if (buttons.isButtonLeftHeld()) { - drawFunction(g2,heldColor,33,77); - } - if (buttons.isButtonLeftJustReleased()) { - drawFunction(g2,releasedColor,33,77); - } - - /* button RIGHT */ - if (buttons.isButtonRightJustPressed()) { - drawFunction(g2,pressedColor,73,77); - } - if (buttons.isButtonRightHeld()) { - drawFunction(g2,heldColor,73,77); - } - if (buttons.isButtonRightJustReleased()) { - drawFunction(g2,releasedColor,73,77); - } - - /* button UP */ - if (buttons.isButtonUpJustPressed()) { - drawFunction(g2,pressedColor,54,60); - } - if (buttons.isButtonUpHeld()) { - drawFunction(g2,heldColor,54,60); - } - if (buttons.isButtonUpJustReleased()) { - drawFunction(g2,releasedColor,54,60); - } - - /* button DOWN */ - if (buttons.isButtonDownJustPressed()) { - drawFunction(g2,pressedColor,54,97); - } - if (buttons.isButtonDownHeld()) { - drawFunction(g2,heldColor,54,97); - } - if (buttons.isButtonDownJustReleased()) { - drawFunction(g2,releasedColor,54,97); - } - - /* button MINUS */ - if (buttons.isButtonMinusJustPressed()) { - drawFunction(g2,pressedColor,20,230); - } - if (buttons.isButtonMinusHeld()) { - drawFunction(g2,heldColor,20,230); - } - if (buttons.isButtonMinusJustReleased()) { - drawFunction(g2,releasedColor,20,230); - } - - /* button PLUS */ - if (buttons.isButtonPlusJustPressed()) { - drawFunction(g2,pressedColor,86,230); - } - if (buttons.isButtonPlusHeld()) { - drawFunction(g2,heldColor,86,230); - } - if (buttons.isButtonPlusJustReleased()) { - drawFunction(g2,releasedColor,86,230); - } - - /* button HOME */ - if (buttons.isButtonHomeJustPressed()) { - drawFunction(g2,pressedColor,53,230); - } - if (buttons.isButtonHomeHeld()) { - drawFunction(g2,heldColor,53,230); - } - if (buttons.isButtonHomeJustReleased()) { - drawFunction(g2,releasedColor,53,230); - } - - buttons = null; - } - - - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * Function used to factorize code. - * @param g2 where to draw a shape. - * @param col color to use. - * @param x x coordinates. - * @param y y coordinates. - */ - private void drawFunction(Graphics2D g2, Color col, int x, int y) { - g2.setPaint(col); - g2.translate(x, y); - g2.draw(shape); - g2.fill(shape); - g2.setTransform(new AffineTransform()); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); - buttons = arg0; - repaint(); - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - 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() { - - 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/WiiUseJ_0.1/src/wiiusej/utils/GForcePanel.java b/WiiUseJ_0.1/src/wiiusej/utils/GForcePanel.java deleted file mode 100644 index 9802688..0000000 --- a/WiiUseJ_0.1/src/wiiusej/utils/GForcePanel.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.GForce; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch gravity force values from a MotionSensingEvent. - * @author guiguito - */ -public class GForcePanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor of the AccelerationPanel. - */ - public GForcePanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * @param bgColor background color. - * @param xxColor color of the acceleration on X axis. - * @param yyColor color of the acceleration on Y axis. - * @param zzColor color of the acceleration on Z axis. - * @param lColor line color. - */ - public GForcePanel(Color bgColor, Color xxColor, Color yyColor, Color zzColor, Color lColor) { - backgroundColor = bgColor; - xColor = xxColor; - yColor = yyColor; - zColor = zzColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - GForce[] valuesArray = values.toArray(new GForce[0]); - double unit = yMiddleFloat / 5.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - GForce gforce = valuesArray[i]; - //draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * gforce.getX()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - //draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * gforce.getY()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - //draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * gforce.getZ()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } - - //draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("5", 2, 10); - g2.drawString("-5", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getGforce()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.1/src/wiiusej/utils/IRPanel.java b/WiiUseJ_0.1/src/wiiusej/utils/IRPanel.java deleted file mode 100644 index b4213a1..0000000 --- a/WiiUseJ_0.1/src/wiiusej/utils/IRPanel.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what the IR camera of the wiimote sees. - * @author guiguito - */ -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; - - /** - * Default constructor for IR Panel. - * Background color : black. - * IR sources color : yellow. - * Border color of IR sources : blue. - * Shape of the IR sources : circle with a diameter of 10. - */ - public IRPanel() { - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); - initArrays(); - initComponents(); - } - - /** - * Constructor used to parameterize the IR panel. - * @param bgColor color. - * @param ptColor IR sources color. - * @param bdColor border color of IR sources. - * @param sh Shape of the IR sources. - */ - public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { - backgroundColor = bgColor; - color = ptColor; - borderColor = bdColor; - shape = sh; - initArrays(); - initComponents(); - } - - private void initArrays(){ - xCoordinates = new int[MAX_NB_POINTS]; - yCoordinates = new int[MAX_NB_POINTS]; - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw points - int i = 0; - while (xCoordinates[i] != -1 && yCoordinates[i] != -1 && i < nbPoints) { - double x = xCoordinates[i]; - double y = yCoordinates[i]; - - long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); - long yy = getHeight() - Math.round((double) getHeight() * y / 768.0); - g2.translate(xx, yy); - - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(color); - g2.fill(shape); - - g2.setTransform(new AffineTransform()); - i++; - } - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //transfer points - wiiusej.values.IRSource[] points = arg0.getIRPoints(); - nbPoints = points.length; - for (int i = 0; i < points.length; i++) { - xCoordinates[i] = (int) points[i].getRx(); - yCoordinates[i] = (int) points[i].getRy(); - } - for (int i = points.length; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - - //redraw panel - repaint(); - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void 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(); - } - - /** 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 -} diff --git a/WiiUseJ_0.1/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ_0.1/src/wiiusej/utils/OrientationPanel.java deleted file mode 100644 index b50a2ce..0000000 --- a/WiiUseJ_0.1/src/wiiusej/utils/OrientationPanel.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.Orientation; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch orientation values from a MotionSensingEvent. - * @author guiguito - */ -public class OrientationPanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor. - * Background color : White. - * Roll color : Red. - * Pitch color : Green. - * Yaw color : Blue. - */ - public OrientationPanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the OrientationPanel. - * @param bgColor background color. - * @param rColor roll color. - * @param pColor pitch color. - * @param yColor yaw color. - * @param lColor line color. - */ - public OrientationPanel(Color bgColor, Color rColor, Color pColor, Color yColor, Color lColor) { - backgroundColor = bgColor; - rollColor = rColor; - pitchColor = pColor; - yawColor = yColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - Orientation[] valuesArray = values.toArray(new Orientation[0]); - double unit = yMiddleFloat / 180.0; - int previousRoll = 0; - int previousPitch = 0; - int previousYaw = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - Orientation orientation = valuesArray[i]; - //draw roll - g2.setPaint(rollColor); - int yDelta = (int) Math.round(unit * orientation.getRoll()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousRoll, i, y); - g2.setTransform(new AffineTransform()); - previousRoll = y; - //draw pitch - g2.setPaint(pitchColor); - yDelta = (int) Math.round(unit * orientation.getPitch()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousPitch, i, y); - g2.setTransform(new AffineTransform()); - previousPitch = y; - //draw yaw - g2.setPaint(yawColor); - yDelta = (int) Math.round(unit * orientation.getYaw()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousYaw, i, y); - g2.setTransform(new AffineTransform()); - previousYaw = y; - } - - //draw legend - g2.setPaint(rollColor); - g2.drawLine(5, getHeight()-10, 25, getHeight()-10); - g2.setPaint(pitchColor); - g2.drawLine(60, getHeight()-10, 80, getHeight()-10); - g2.setPaint(yawColor); - g2.drawLine(120, getHeight()-10, 140, getHeight()-10); - - g2.setPaint(lineColor); - g2.drawString("Roll", 30, getHeight()-5); - g2.drawString("Pitch", 85, getHeight()-5); - g2.drawString("Yaw", 145, getHeight()-5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("180", 2, 10); - g2.drawString("-180", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getOrientation()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.1/src/wiiusej/values/GForce.java b/WiiUseJ_0.1/src/wiiusej/values/GForce.java deleted file mode 100644 index 9732121..0000000 --- a/WiiUseJ_0.1/src/wiiusej/values/GForce.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents gravity force on each axis. - * @author guiguito - */ -public class GForce { - - private float x; - private float y; - private float z; - - /** - * 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; - } - - /** - * @return the x - */ - public float getX() { - return x; - } - - /** - * @return the y - */ - public float getY() { - return y; - } - - /** - * @return the z - */ - public float getZ() { - return z; - } - - @Override - public String toString() { - return "Gravity force : ("+x+", "+y+","+z+")"; - } -} diff --git a/WiiUseJ_0.1/src/wiiusej/values/IRSource.java b/WiiUseJ_0.1/src/wiiusej/values/IRSource.java deleted file mode 100644 index 7caef55..0000000 --- a/WiiUseJ_0.1/src/wiiusej/values/IRSource.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class used for IR sources. - * @author guiguito - */ -public class IRSource{ - - 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; - } - - - /** - * 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 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 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+")"; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/values/Orientation.java b/WiiUseJ_0.1/src/wiiusej/values/Orientation.java deleted file mode 100644 index 4c4f741..0000000 --- a/WiiUseJ_0.1/src/wiiusej/values/Orientation.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class that represents the orientation of the wiimote. - * @author guiguito - */ -public class Orientation { - - private float roll; - private float pitch; - private float yaw; - - /** - * Default constructor. - */ - public Orientation(){ - roll = 0; - pitch = 0; - yaw = 0; - } - - /** - * Contructor with raw, pitch , yaw. - * @param r raw - * @param p pitch - * @param y yaw - */ - public Orientation(float r, float p, float y){ - roll = r; - pitch = p; - yaw = y; - } - - /** - * @return the roll - */ - public float getRoll() { - return roll; - } - - /** - * @return the pitch - */ - public float getPitch() { - return pitch; - } - - /** - * @return the yaw - */ - public float getYaw() { - return yaw; - } - - @Override - public String toString() { - return "Orientation : (roll: "+roll+", pitch: "+pitch+", yaw: "+yaw+")"; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/values/RawAcceleration.java b/WiiUseJ_0.1/src/wiiusej/values/RawAcceleration.java deleted file mode 100644 index 903a51c..0000000 --- a/WiiUseJ_0.1/src/wiiusej/values/RawAcceleration.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents raw acceleration on each axis. - * @author guiguito - */ -public class RawAcceleration { - - private short x; - private short y; - private short z; - - /** - * 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; - } - - /** - * @return the x - */ - public short getX() { - return x; - } - /** - * @return the y - */ - public short getY() { - return y; - } - - /** - * @return the z - */ - public short getZ() { - return z; - } - - @Override - public String toString() { - return "Raw acceleration : ("+x+", "+y+","+z+")"; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/ButtonsEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/ButtonsEvent.java deleted file mode 100644 index ce78551..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/ButtonsEvent.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class which represents a buttons event. - * @author guiguito - */ -public class ButtonsEvent extends WiimoteEvent{ - - /* 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 */ - 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); - } - - /** - * 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 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; - } - - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ - - private boolean buttonTest(short buttonBitsDefinition, short buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } - - private boolean isButtonJustPressed(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } - - private boolean isButtonJustReleased(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } - - private boolean isButtonHeld(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } - - private boolean isButtonPressed(short buttonBitsDefinition) { - return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition); - } - /* Button ONE */ - - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOnePressed() { - return isButtonPressed(WIIMOTE_BUTTON_ONE); - } - - /* Button TWO */ - - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoPressed() { - return isButtonPressed(WIIMOTE_BUTTON_TWO); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAPressed() { - return isButtonPressed(WIIMOTE_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBPressed() { - return isButtonPressed(WIIMOTE_BUTTON_B); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftPressed() { - return isButtonPressed(WIIMOTE_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightPressed() { - return isButtonPressed(WIIMOTE_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpPressed() { - return isButtonPressed(WIIMOTE_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownPressed() { - return isButtonPressed(WIIMOTE_BUTTON_DOWN); - } - - /* Button - */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_MINUS); - } - - /* Button + */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_PLUS); - } - - /* Button HOME */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomePressed() { - return isButtonPressed(WIIMOTE_BUTTON_HOME); - } - - @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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/DisconnectionEvent.java deleted file mode 100644 index 341b626..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/DisconnectionEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class representing a disconnection event. - * @author guiguito - */ -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); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; - - return out; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/EventsGatherer.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/EventsGatherer.java deleted file mode 100644 index 5c83d78..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/EventsGatherer.java +++ /dev/null @@ -1,241 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class is used to gather events during a call to the Wiiuse API. - * - * @author guiguito - */ -public class EventsGatherer { - - private WiiUseApiEvent[] events; - private int index = 0; - private GenericEvent 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]; - } - - /** - * 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 GenericEvent(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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, - yOffset, sensorBarPostion, screenAsPectRatio); - - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - if (genericEvent != null) { - genericEvent.setMotionSensingEvent(orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, - ya, x, y, z, xx, yy, zz); - } - } - - /** - * 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 DisconnectionEvent to the gatherer. - * - * @param id - * id of the wiimote - */ - public void addDisconnectionEvent(int id) { - DisconnectionEvent evt = new DisconnectionEvent(id); - addEvent(evt); - } - - /** - * Return an array containing the events. - * - * @return events received - */ - public WiiUseApiEvent[] getEvents() { - return java.util.Arrays.copyOfRange(events, 0, index); - } - - /** - * 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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/GenericEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/GenericEvent.java deleted file mode 100644 index e8ea39b..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/GenericEvent.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class that is a bean to be filled by the wiiuse API. - * - * @author guiguito - */ -public class GenericEvent extends WiiUseApiEvent { - - ButtonsEvent buttonsEvent = null; - IREvent infraredEvent = null; - MotionSensingEvent motionSensingEvent = null; - - /** - * Construct the Wiimote setting up the id. - * - * @param id - * the Wiimote id - */ - public GenericEvent(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 GenericEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, WiiUseApiEvent.GENERIC_EVENT); - buttonsEvent = new ButtonsEvent(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 a motion sensing Event. - * - * @return TRUE if there is a motion sensing event. - */ - public boolean isThereMotionSensingEvent() { - return motionSensingEvent != null; - } - - /** - * Get buttons event. - * - * @return the buttons event. - */ - public ButtonsEvent getButtonsEvent() { - return buttonsEvent; - } - - /** - * Get IR event. - * - * @return the IR event if there is one or null. - */ - public IREvent getIREvent() { - return infraredEvent; - } - - /** - * Get motion sensing event. - * - * @return the motion sensing event if there is one or null. - */ - public MotionSensingEvent getMotionSensingEvent() { - return motionSensingEvent; - } - - /** - * 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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - if (infraredEvent == null) { - infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, - yVRes, xOffset, yOffset, sensorBarPostion, - screenAsPectRatio); - } - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - motionSensingEvent = new MotionSensingEvent(getWiimoteId(), - orientationThreshold, accelerationThreshold, smoothingState, - alphaSmooth, r, p, ya, x, y, z, xx, yy, zz); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GENERIC EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - - out += buttonsEvent; - - 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"; - } - - return out; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/IREvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/IREvent.java deleted file mode 100644 index 6007e97..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/IREvent.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.IRSource; - -/** - * Class which represents an IR event. - * - * @author guiguito - */ -public class IREvent extends WiimoteEvent { - - /* IR Tracking */ - private IRSource[] IRPoints; - private short indexPoints = 0; - private int x; - private int y; - private int 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; - - 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 - - /** - * 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. - */ - public IREvent(int id, int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - 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; - IRPoints = new IRSource[NB_POINTS]; - } - - /** - * Get list of IR points. - * - * @return the list of 2D points - */ - public IRSource[] getIRPoints() { - return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints); - } - - /** - * 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 Y coordinate. - * - * @return the y - */ - public int getY() { - return y; - } - - /** - * Return calculated distance. - * - * @return the z - */ - public int getZ() { - return z; - } - - /** - * 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 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 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 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 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 aspect ratio of the screen. - * - * @return the screenAsPectRatio - */ - public short getScreenAsPectRatio() { - return screenAsPectRatio; - } - - @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 distance : " + z + "\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"; - 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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/MotionSensingEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/MotionSensingEvent.java deleted file mode 100644 index 6ec7712..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/MotionSensingEvent.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.GForce; -import wiiusej.values.Orientation; -import wiiusej.values.RawAcceleration; - -/** - * Class which represents a motion sensing event. - * - * @author guiguito - */ -public class MotionSensingEvent extends WiimoteEvent { - - /* 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; - - /** - * 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 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 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, x, y, z, xx, yy, zz); - } - - /** - * Set orientation, gravity force and raw acceleration. - * - * @param r - * roll - * @param p - * pitch - * @param ya - * yaw - * @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 x, - float y, float z, short xx, short yy, short zz) { - this.orientation = new Orientation(r, p, ya); - this.gforce = new GForce(x, y, z); - this.acceleration = new RawAcceleration(xx, yy, zz); - } - - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * 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 orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } - - /** - * Get acceleration threshold. - * - * @return the accelerationThreshold - */ - public int getAccelerationThreshold() { - return accelerationThreshold; - } - - /** - * 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; - } - - @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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/StatusEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/StatusEvent.java deleted file mode 100644 index 7a365fc..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/StatusEvent.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class used to represent a status event. This class is used to know what are - * the settings of the wiimote. - * - * @author guiguito - */ -public class StatusEvent extends WiiUseApiEvent { - - private static short WIIMOTE_LED_1 = 1; - private static short WIIMOTE_LED_2 = 2; - private static short WIIMOTE_LED_3 = 4; - private static short WIIMOTE_LED_4 = 8; - - /* 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; - - /* Status variables */ - private boolean connected = false; - - private float batteryLevel = -1; - - private short leds = 0; - - private boolean isSpeakerEnabled = false; - - private int attachment = 0; - - private boolean isRumbleActive = false; - - private boolean isContinuousActive = false; - - private boolean isIrActive = 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); - } - - /** - * 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; - } - - /** - * 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 led1 status. - * - * @return true if the led is set. - */ - public boolean isLed1Set() { - if ((leds & WIIMOTE_LED_1) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led2 status. - * - * @return true if the led is set. - */ - public boolean isLed2Set() { - if ((leds & WIIMOTE_LED_2) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led3 status. - * - * @return true if the led is set. - */ - public boolean isLed3Set() { - if ((leds & WIIMOTE_LED_3) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led4 status. - * - * @return true if the led is set. - */ - public boolean isLed4Set() { - if ((leds & WIIMOTE_LED_4) > 0) { - return true; - } else { - return false; - } - } - - /** - * 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 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 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; - } - - @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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java deleted file mode 100644 index 880c632..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class describes the structure of an event from the WiiUse API event. - * - * @author guiguito - */ -public abstract class WiiUseApiEvent extends WiimoteEvent{ - - public static int GENERIC_EVENT = 1; - public static int STATUS_EVENT = 2; - public static int DISCONNECTION_EVENT = 3; - public static int WIIUSE_NUNCHUK_INSERTED = 4; - public static int WIIUSE_NUNCHUK_REMOVED = 5; - public static int WIIUSE_CLASSIC_CTRL_INSERTED = 6; - public static int WIIUSE_CLASSIC_CTRL_REMOVED = 7; - public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 8; - public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 9; - - /* 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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiListener.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiListener.java deleted file mode 100644 index 3f6bb22..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiiUseApiListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - - - -/** - * This is the interface to implement to listen to events from the wiiuse API. - * - * @author guiguito - */ -public interface WiiUseApiListener extends java.util.EventListener { - - /** - * Method called when a WiiUseApiEvent occurs. - * A WiiUseApiEvent can be : - * - GenericEvent (Storing ButtonsEvent and - * eventually IREvent and MotionSensingEvent) - * - StatusEvent - * - DisconnectionEvent - * @param e - */ - void onWiiUseApiEvent(WiiUseApiEvent e); - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteEvent.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteEvent.java deleted file mode 100644 index 1504a37..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Abstract mother class representing an event with a wiimote id. - * - * @author guiguito - */ -public abstract class WiimoteEvent { - - /* ID */ - private int wiimoteId = -1; - - /** - * Construct the WiiUseApiEvent setting up the id. - * - * @param id - * the Wiimote id - */ - public WiimoteEvent(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/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteListener.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteListener.java deleted file mode 100644 index 3ea3c05..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapievents/WiimoteListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This is the interface to implement to listen to events from wiimotes. - * The differents methods are called in this order : - * onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent. - * - * @author guiguito - */ -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(ButtonsEvent 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 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); - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/FloatValueRequest.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/FloatValueRequest.java deleted file mode 100644 index a003239..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/FloatValueRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with a float value to pass to wiiuse API. - * - * @author guiguito - */ -public class FloatValueRequest extends WiiUseApiRequest { - - private float floatValue; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public FloatValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * threshold in degrees - */ - public FloatValueRequest(int id, int type, float th) { - super(id, type); - floatValue = th; - } - - /** - * Get the float value. - * @return the float value - */ - public float getFloatValue() { - return floatValue; - } - - /** - * Set the float value. - * @param val the value to set - */ - public void setFloatValue(float val) { - this.floatValue = val; - } - - - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/IntValueRequest.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/IntValueRequest.java deleted file mode 100644 index 801093d..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/IntValueRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with an int value to pass to wiiuse API. - * - * @author guiguito - */ -public class IntValueRequest extends WiiUseApiRequest { - - private int intValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id - * the id of the wiimote concerned. - */ - public IntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the int value. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * the int value. - */ - public IntValueRequest(int id, int type, int th) { - super(id, type); - intValue = th; - } - - /** - * Get the int value. - * @return the int value - */ - public int getIntValue() { - return intValue; - } - - /** - * Set the int value. - * @param val the value to set - */ - public void setIntValue(int val) { - this.intValue = val; - } - - - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/LedsRequest.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/LedsRequest.java deleted file mode 100644 index 1a21024..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/LedsRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request to set leds of the wiimote with WiiUse API. - * - * @author guiguito - */ -public class LedsRequest extends wiiusej.wiiuseapirequest.WiiUseApiRequest { - - private boolean led1, led2, led3, led4; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - */ - public LedsRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - * @param l1 - * led1 status. True=ON, False=OFF - * @param l2 - * led2 status. True=ON, False=OFF - * @param l3 - * led3 status. True=ON, False=OFF - * @param l4 - * led4 status. True=ON, False=OFF - */ - public LedsRequest(int id, int type, boolean l1, boolean l2, boolean l3, - boolean l4) { - super(id, type); - led1 = l1; - led2 = l2; - led3 = l3; - led4 = l4; - } - - /** - * @return the led1 - */ - public boolean isLed1() { - return led1; - } - - /** - * @param led1 - * the led1 to set - */ - public void setLed1(boolean led1) { - this.led1 = led1; - } - - /** - * @return the led2 - */ - public boolean isLed2() { - return led2; - } - - /** - * @param led2 - * the led2 to set - */ - public void setLed2(boolean led2) { - this.led2 = led2; - } - - /** - * @return the led3 - */ - public boolean isLed3() { - return led3; - } - - /** - * @param led3 - * the led3 to set - */ - public void setLed3(boolean led3) { - this.led3 = led3; - } - - /** - * @return the led4 - */ - public boolean isLed4() { - return led4; - } - - /** - * @param led4 - * the led4 to set - */ - public void setLed4(boolean led4) { - this.led4 = led4; - } - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java deleted file mode 100644 index 98e907e..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - - -/** - * Represents a request with two int values to pass to wiiuse API. - * - * @author guiguito - */ -public class TwoIntValueRequest extends IntValueRequest { - - private int secondIntValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - */ - public TwoIntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the two int values. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - * @param x first int value. - * @param y second int value. - */ - public TwoIntValueRequest(int id, int type, int x, int y) { - super(id, type, x); - secondIntValue = y; - } - - /** - * Get the second int value. - * @return the secondIntValue - */ - public int getSecondIntValue() { - return secondIntValue; - } - - /** - * Set the second int value. - * @param secondIntValue the secondIntValue to set. - */ - public void setSecondIntValue(int secondIntValue) { - this.secondIntValue = secondIntValue; - } - - - -} diff --git a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java b/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java deleted file mode 100644 index 1f4525b..0000000 --- a/WiiUseJ_0.1/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request we could do to the WiiUse API. - * - * @author guiguito - */ -public class WiiUseApiRequest { - - public static int WIIUSE_STATUS_REQUEST = 1; - public static int WIIUSE_ACTIVATE_SMOOTHING_REQUEST = 2; - public static int WIIUSE_DEACTIVATE_SMOOTHING_REQUEST = -2; - public static int WIIUSE_ACTIVATE_IR_TRACKING_REQUEST = 3; - public static int WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST = -3; - public static int WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST = 4; - public static int WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST = -4; - public static int WIIUSE_CLOSE_CONNECTION_REQUEST = 5; - public static int WIIUSE_ACTIVATE_CONTINUOUS_REQUEST = 6; - public static int WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST = -6; - public static int WIIUSE_ACTIVATE_RUMBLE_REQUEST = 7; - public static int WIIUSE_DEACTIVATE_RUMBLE_REQUEST = -7; - public static int WIIUSE_LEDS_REQUEST = 8; - public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9; - public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10; - public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11; - public static int WIIUSE_RESYNC = 12; - public static int WIIUSE_ASPECT_RATIO_4_3 = 13; - public static int WIIUSE_ASPECT_RATIO_16_9 = 14; - public static int WIIUSE_SENSOR_BAR_ABOVE = 15; - public static int WIIUSE_SENSOR_BAR_BELOW = 16; - public static int WIIUSE_SET_VIRTUAL_RESOLUTION = 17; - - private int wiimoteId = 0; - private int requestType = 0; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public WiiUseApiRequest(int id) { - wiimoteId = id; - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * - */ - public WiiUseApiRequest(int id, int type) { - wiimoteId = id; - requestType = type; - } - - /** - * Get id of the wiimote concerned by this request. - * - * @return id of the wiimote concerned - */ - public int getId() { - return wiimoteId; - } - - /** - * Set id of the wiimote concerned by this request. - * - * @param id - * id fh the wiimote concernet - */ - public void setId(int id) { - wiimoteId = id; - } - - /** - * Get the request type. - * - * @return the requestType - */ - public int getRequestType() { - return requestType; - } - - /** - * Set the request type. - * - * @param requestType - * the requestType to set - */ - public void setRequestType(int requestType) { - this.requestType = requestType; - } - -} diff --git a/WiiUseJ_0.1/wiiuse.dll b/WiiUseJ_0.1/wiiuse.dll deleted file mode 100644 index 6855619..0000000 Binary files a/WiiUseJ_0.1/wiiuse.dll and /dev/null differ diff --git a/WiiUseJ_0.11/.classpath b/WiiUseJ_0.11/.classpath deleted file mode 100644 index d171cd4..0000000 --- a/WiiUseJ_0.11/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/WiiUseJ_0.11/.project b/WiiUseJ_0.11/.project deleted file mode 100644 index 9485f4a..0000000 --- a/WiiUseJ_0.11/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - WiiUseJava - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/WiiUseJ_0.11/README.TXT b/WiiUseJ_0.11/README.TXT deleted file mode 100644 index 268d31d..0000000 --- a/WiiUseJ_0.11/README.TXT +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ - - -WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI. - -WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes. - -Some of the great aspects of this API are : - - * The compatibility which is as large as Wiiuse's API compatibility - - * Cross-platform : Windows and linux (like Wiiuse) - - * Easy to use - - -WiiuseJ is made by Guilhem Duché : guiguito1@hotmail.com. -You can contact me if you need more information. - -Go to : http://wiiusej.googlecode.com/ for further documentations. - - - diff --git a/WiiUseJ_0.11/WiiUseJ.dll b/WiiUseJ_0.11/WiiUseJ.dll deleted file mode 100644 index 6999b85..0000000 Binary files a/WiiUseJ_0.11/WiiUseJ.dll and /dev/null differ diff --git a/WiiUseJ_0.11/img/wiimote.png b/WiiUseJ_0.11/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.11/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.11/libWiiuseJ.so b/WiiUseJ_0.11/libWiiuseJ.so deleted file mode 100644 index 47ab1f2..0000000 Binary files a/WiiUseJ_0.11/libWiiuseJ.so and /dev/null differ diff --git a/WiiUseJ_0.11/libwiiuse.so b/WiiUseJ_0.11/libwiiuse.so deleted file mode 100644 index 2f9247b..0000000 Binary files a/WiiUseJ_0.11/libwiiuse.so and /dev/null differ diff --git a/WiiUseJ_0.11/src/img/wiimote.png b/WiiUseJ_0.11/src/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.11/src/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java b/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java deleted file mode 100644 index 3f169e6..0000000 --- a/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java +++ /dev/null @@ -1,265 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import wiiusej.wiiuseapievents.EventsGatherer; - -/** - * Singleton used to manipulate WiiUse Api. - * - * @author guiguito - */ -public class WiiUseApi { - - static { - System.loadLibrary("WiiuseJ"); - } - - private static WiiUseApi instance = new WiiUseApi(); - - /** - * Get the only instance of WiiUseApi. - * - * @return the only instace of WiiUseApi. - */ - static WiiUseApi getInstance() { - return instance; - } - - /** - * Try to connect to 2 wiimotes. Make them rumble to show they are - * connected. - * - * @param nb - * number of wiimotes to connect - * @param rumble - * make the connected wiimotes rumble - * @return 0 if there is an error otherwise it returns the number of - * wiimotes connected. - */ - native int doConnections(int nb, boolean rumble); - - /** - * Close connection to the wiimote with the given id. - * - */ - native void closeConnection(int id); - - /** - * Shutdown Wiiuse API. - */ - native void shutdownApi(); - - /** - * Activate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateRumble(int id); - - /** - * Deactivate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void deactivateRumble(int id); - - /** - * Activate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateIRTracking(int id); - - /** - * Deactivate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void deactivateIRTracking(int id); - - /** - * Activate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateMotionSensing(int id); - - /** - * Deactivate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - native void activateSmoothing(int id); - - /** - * Make the the accelerometers give raw results. - * - * @param id - * the id of the wiimote concerned - */ - 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 - */ - native void activateContinuous(int id); - - /** - * Make the wiimote generate an event only when there is one. - * - * @param id - * the id of the wiimote concerned - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - native void getStatus(int id); - - /** - * 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/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java b/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java deleted file mode 100644 index 2d258d5..0000000 --- a/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java +++ /dev/null @@ -1,571 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.EventsGatherer; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapirequest.FloatValueRequest; -import wiiusej.wiiuseapirequest.IntValueRequest; -import wiiusej.wiiuseapirequest.LedsRequest; -import wiiusej.wiiuseapirequest.TwoIntValueRequest; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that manages the use of Wiiuse API. - * - * @author guiguito - */ -public class WiiUseApiManager extends Thread { - - private static WiiUseApiManager instance = new WiiUseApiManager(); - - private final EventListenerList listeners = new EventListenerList(); - - private Wiimote[] wiimotes; - - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - - private int connected = -1; - - private int nbMaxWiimotes = -1; - - private AtomicBoolean running = new AtomicBoolean(false); - - private ConcurrentLinkedQueue requests = new ConcurrentLinkedQueue(); - - 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 synchronized static Wiimote[] getWiimotes(int nb, boolean rumble) { - WiiUseApiManager manager = getInstance(); - if (manager.connected < 0) { - int nbWiimotes = manager.connectWiimotes(nb, rumble); - manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i = 1; i <= nbWiimotes; i++) { - Wiimote wim = new Wiimote(i, manager); - manager.wiimotes[i - 1] = wim; - manager.addWiiUseApiListener(wim); - } - } - - if (manager.connected == 0) { - return new Wiimote[0]; - } - - if (!manager.isAlive()) - manager.start(); - - 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 - * @return 0 if nothing connected or the number of wiimotes connected. - */ - private int connectWiimotes(int nb, boolean rumble) { - nbMaxWiimotes = nb; - if (connected < 0) { - connected = wiiuse.doConnections(nb, rumble); - 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. - */ - public void closeConnection(int id) { - removeWiiUseApiListener(wiimotes[id - 1]); - wiimotes[id - 1] = null; - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST)); - // System.out.println("Wiimote " + id + " disconnected !"); - } - - /** - * Get the number of wiimotes connected. - * - * @return the number of wiimotes connected. - */ - public int getNbConnectedWiimotes() { - return connected; - } - - /** - * Stop thread and shutdown wiiuse Api. - */ - public void shutdown() { - if (connected > 0) { - for (Wiimote wim : wiimotes) { - if (wim != null) - wim.disconnect(); - } - } - running.set(false); - wiiuse.shutdownApi(); - } - - /** - * Activate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Deactivate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Activate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Deactivate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Activate motion sensing for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Deactivate motion sensing for the wiimoter with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Activate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Deactivate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Activate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * Deactivate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote - */ - public void deactivateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * 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 - */ - public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) { - requests.add(new LedsRequest(id, WiiUseApiRequest.WIIUSE_LEDS_REQUEST, - l1, l2, l3, l4)); - } - - /** - * Set the orientation threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(int id, float th) { - requests.add(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST, th)); - } - - /** - * Set the acceleration threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAccelerationThreshold(int id, int th) { - requests.add(new IntValueRequest(id, - WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th)); - } - - /** - * Set alpha smoothing for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAlphaSmoothing(int id, float th) { - requests.add(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th)); - } - - /** - * Try to resync with the wiimote by starting a new handshake. - * - * @param id - * id of the wiimote - */ - public void reSync(int id) { - requests.add(new WiiUseApiRequest(id, WiiUseApiRequest.WIIUSE_RESYNC)); - } - - /** - * Set screen aspect ratio to 4/3 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio43(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3)); - } - - /** - * Set screen aspect ratio to 16/9 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio169(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9)); - } - - /** - * Set the sensor bar to be above the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarAboveScreen(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE)); - } - - /** - * Set the sensor bar to be below the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarBelowScreen(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW)); - } - - /** - * 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 - */ - public void setVirtualResolution(int id, int x, int y) { - requests.add(new TwoIntValueRequest(id, - WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION, x, y)); - } - - /** - * Get Status for the wiimote for the given id. - * - * @param id - * id of the wiimote - */ - public void getStatus(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_STATUS_REQUEST)); - } - - @Override - public void run() { - - if (connected > 0) { - running.set(true); - - EventsGatherer gather = new EventsGatherer(nbMaxWiimotes); - - // Start polling and tell the observers when there Wiimote events - while (running.get() && connected > 0) { - - /* 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(); - - /* deal with request done to wiiuse API */ - WiiUseApiRequest req = requests.poll(); - if (req != null) {// there is a request for the wiiuse api - int id = req.getId(); - if (req.getRequestType() == WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST) { - /* Close connections requests */ - wiiuse.closeConnection(id); - - connected--; - if (connected == 0) {// stop this thread if there is - // no more wiimotes connected. - // System.out.println("No more wiimotes connected - // !!!"); - shutdown(); - } - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) { - /* Status requests */ - wiiuse.getStatus(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST) { - /* Activate Rumble requests */ - wiiuse.activateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST) { - /* Deactivate Rumble requests */ - wiiuse.deactivateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST) { - /* Activate IR Tracking requests */ - wiiuse.activateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST) { - /* Deactivate IR Tracking requests */ - wiiuse.deactivateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST) { - /* Activate Motion sensing requests */ - wiiuse.activateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST) { - /* Deactivate Motion sensing requests */ - wiiuse.deactivateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_LEDS_REQUEST) { - /* leds requests */ - LedsRequest reqLed = (LedsRequest) req; - wiiuse.setLeds(id, reqLed.isLed1(), reqLed.isLed2(), - reqLed.isLed3(), reqLed.isLed4()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST) { - /* Activate smoothing requests */ - wiiuse.activateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST) { - /* Deactivate smoothing requests */ - wiiuse.deactivateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST) { - /* Activate continuous requests */ - wiiuse.activateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST) { - /* Deactivate continuous requests */ - wiiuse.deactivateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST) { - /* set orientation threshold request */ - wiiuse.setOrientThreshold(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) { - /* set acceleration threshold request */ - wiiuse.setAccelThreshold(req.getId(), - ((IntValueRequest) req).getIntValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) { - /* set alpha smoothing request */ - wiiuse.setAlphaSmoothing(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) { - /* set resync request */ - wiiuse.reSync(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3) { - /* set screen aspect ratio to 4/3 */ - wiiuse.setScreenRatio43(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9) { - /* set screen aspect ratio to 16/9 */ - wiiuse.setScreenRatio169(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarAboveScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarBelowScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION) { - /* set virtual resolution */ - wiiuse.setVirtualScreenResolution(req.getId(), - ((TwoIntValueRequest) req).getIntValue(), - ((TwoIntValueRequest) req).getSecondIntValue()); - } else { - System.out.println("Bad request to Wiiuse API !!!!!"); - } - } - } - } else { - if (connected <= 0) { - System.out.println("No wiimotes connected !"); - } - } - - } - - /** - * Add WiiUseApiListener to the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void addWiiUseApiListener(WiiUseApiListener listener) { - listeners.add(WiiUseApiListener.class, listener); - } - - /** - * Remove WiiUseApiListener from the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void removeWiiUseApiListener(WiiUseApiListener listener) { - listeners.remove(WiiUseApiListener.class, listener); - } - - /** - * Get the list of WiiUseApiListeners. - * - * @return the list of WiiUseApiListeners. - */ - public WiiUseApiListener[] getWiiUseApiListeners() { - return listeners.getListeners(WiiUseApiListener.class); - } - - /** - * Notify WiiUseApiListeners that an event occured. - * - * @param evt - * WiimoteEvent occured - */ - private void notifyWiiUseApiListener(WiiUseApiEvent evt) { - for (WiiUseApiListener listener : getWiiUseApiListeners()) { - listener.onWiiUseApiEvent(evt); - } - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/Wiimote.java b/WiiUseJ_0.11/src/wiiusej/Wiimote.java deleted file mode 100644 index f04e66c..0000000 --- a/WiiUseJ_0.11/src/wiiusej/Wiimote.java +++ /dev/null @@ -1,323 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapievents.WiimoteListener; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that represents a wiimote. - * You can register as an observer of this wiimote to listen events from it. - * You manage it. - * @author guiguito - */ -public class Wiimote implements WiiUseApiListener { - - private int id = -1;//wiimote id - - private EventListenerList listeners = new EventListenerList(); - - 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; - } - - /** - * Disconnect this wiimote. - */ - public void disconnect(){ - deactivateIRTRacking(); - deactivateMotionSensing(); - deactivateRumble(); - manager.closeConnection(id); - } - - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } - - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } - - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } - - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } - - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } - - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } - - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } - - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } - - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(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 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 . - * @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 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 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 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); - } - - /** - * 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); - } - - /** - * 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((GenericEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED - ||e.getEventType() == 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){ - notifyStatusEventListeners((StatusEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT){ - notifyDisconnectionEventListeners((DisconnectionEvent)e); - } - } - } - - /** - * 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); - } - - /** - * 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 WiimoteEvent occured - */ - private void notifyWiiMoteEventListeners(GenericEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onButtonsEvent(evt.getButtonsEvent()); - if (evt.isThereIrEvent()){ - listener.onIrEvent(evt.getIREvent()); - } - if (evt.isThereMotionSensingEvent()){ - listener.onMotionSensingEvent(evt.getMotionSensingEvent()); - } - } - } - - /** - * 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 notifyDisconnectionEventListeners(DisconnectionEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onDisconnectionEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : "+id; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java b/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java deleted file mode 100644 index ae136bf..0000000 --- a/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * This class is used to close wiiusej cleanly. - * @author guiguito - */ -public class CloseGuiTestCleanly implements WindowListener{ - - Wiimote wiimote; - - - public CloseGuiTestCleanly(Wiimote wim) { - wiimote = wim; - } - - public void windowOpened(WindowEvent e) { - //nothing - } - - public void windowClosing(WindowEvent e) { - WiiUseApiManager.getInstance().shutdown(); - } - - public void windowClosed(WindowEvent e) { - //nothing - } - - public void windowIconified(WindowEvent e) { - //nothing - } - - public void windowDeiconified(WindowEvent e) { - //nothing - } - - public void windowActivated(WindowEvent e) { - //nothing - } - - public void windowDeactivated(WindowEvent e) { - //nothing - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/test/Main.java b/WiiUseJ_0.11/src/wiiusej/test/Main.java deleted file mode 100644 index daaca2a..0000000 --- a/WiiUseJ_0.11/src/wiiusej/test/Main.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * Main Class to launch WiiuseJ GUI Test. - * @author guiguito - */ -public class Main { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); - if (wiimotes.length>0){ - WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]); - gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); - gui.setVisible(true); - } - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/test/Tests.java b/WiiUseJ_0.11/src/wiiusej/test/Tests.java deleted file mode 100644 index 1a82547..0000000 --- a/WiiUseJ_0.11/src/wiiusej/test/Tests.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.values.IRSource; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This class used to test WiiuseJ. - * - * @author guiguito - */ -public class Tests implements WiimoteListener { - - 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 Wiimote wiimote; - - int dump = DISPLAY_EACH_VALUE; - - public Tests(Wiimote wim) { - wiimote = wim; - wiimote.addWiiMoteEventListeners(this); - try { - robot = new Robot(); - } catch (AWTException e) { - e.printStackTrace(); - } - } - - private static int nb = 0; - - public void onButtonsEvent(ButtonsEvent 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 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 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 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 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 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(); - } - - /* 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 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(); - } - - } 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(); - } - - /* 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); - } - - /* 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(); - } - } - - } - - 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); - } - } - - public void onMotionSensingEvent(MotionSensingEvent e) { - /* display motion sensing */ - 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 !!"); - } - - /** - * @param args - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(4, true); - if (wiimotes.length > 0) { - System.out.println(wiimotes[0]); - Tests tests = 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); - - } -} diff --git a/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java deleted file mode 100644 index 8bac8ae..0000000 --- a/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java +++ /dev/null @@ -1,836 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; -import java.util.logging.Level; -import java.util.logging.Logger; -import wiiusej.utils.IRPanel; -import wiiusej.Wiimote; -import wiiusej.utils.AccelerationPanel; -import wiiusej.utils.GForcePanel; -import wiiusej.utils.ButtonsEventPanel; -import wiiusej.utils.OrientationPanel; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * Gui class to test WiiuseJ. - * @author guiguito - */ -public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListener { - - private Wiimote wiimote; - private Robot robot = null; - private boolean statusMotionRequested = false; - private boolean statusIRRequested = false; - - /** Creates new form WiiuseJGuiTest */ - public WiiuseJGuiTest(Wiimote wiimote) { - initComponents(); - this.wiimote = wiimote; - wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel); - wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); - wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel); - wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel); - wiimote.addWiiMoteEventListeners(this); - wiimote.deactivateContinuous(); - wiimote.deactivateSmoothing(); - wiimote.setScreenAspectRatio169(); - wiimote.setSensorBarBelowScreen(); - getStatusButtonMousePressed(null); - this.addWindowListener(new CloseGuiTestCleanly(wiimote)); - } - - public void onButtonsEvent(ButtonsEvent arg0) { - if (robot != null) { - if (arg0.isButtonAPressed()) { - robot.mousePress(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBPressed()) { - robot.mousePress(InputEvent.BUTTON2_MASK); - - } - if (arg0.isButtonOnePressed()) { - robot.mousePress(InputEvent.BUTTON3_MASK); - - } - if (arg0.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_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.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 onMotionSensingEvent(MotionSensingEvent arg0) { - if (statusMotionRequested){//Status requested - accelerationThresholdTextField.setText(""+arg0.getAccelerationThreshold()); - orientationThresholdTextField.setText(""+arg0.getOrientationThreshold()); - alphaSmoothingTextField.setText(""+arg0.getAlphaSmoothing()); - statusMotionRequested = false; - } - } - - public void onStatusEvent(StatusEvent arg0) { - messageText.setText("Status received !"); - batteryLevelText.setText(arg0.getBatteryLevel() + " %"); - led1Button.setEnabled(arg0.isLed1Set()); - led2Button.setEnabled(arg0.isLed2Set()); - led3Button.setEnabled(arg0.isLed3Set()); - led4Button.setEnabled(arg0.isLed4Set()); - //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 !"); - } - - /** 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() { - - leftPanel = new javax.swing.JPanel(); - irViewPanel = new IRPanel(); - jTabbedPane1 = new javax.swing.JTabbedPane(); - motionSensingPanel = new OrientationPanel(); - gForcePanel = new wiiusej.utils.GForcePanel(); - accelerationPanel = new AccelerationPanel(); - rightPanel = new javax.swing.JPanel(); - fixedWiimotePanel = new javax.swing.JPanel(); - buttonsPanel = new ButtonsEventPanel(); - controlsPanel = new javax.swing.JPanel(); - activateRumblePanel = new javax.swing.JPanel(); - toggleRumbleButton = new javax.swing.JButton(); - deactivateRumblePanel = new javax.swing.JPanel(); - toggleIRTrackingButton = new javax.swing.JButton(); - activateIRtrackingPanel = new javax.swing.JPanel(); - toggleMotionSensingTrackingButton = new javax.swing.JButton(); - deactivateIRTrackingPanel = new javax.swing.JPanel(); - toggleSmoothingButton = new javax.swing.JButton(); - activateMotionSensingTrackingPanel = new javax.swing.JPanel(); - toggleContinuousButton = new javax.swing.JButton(); - deactivateMotionSensingTrackingPanel = new javax.swing.JPanel(); - led1Button = new javax.swing.JButton(); - led2Button = new javax.swing.JButton(); - led3Button = new javax.swing.JButton(); - led4Button = new javax.swing.JButton(); - setLedsButton = new javax.swing.JButton(); - activateSmoothingPanel = new javax.swing.JPanel(); - alphaSmoothingTextField = new javax.swing.JTextField(); - alphaSmoothingButton = new javax.swing.JButton(); - deactivateSmoothingPanel = new javax.swing.JPanel(); - orientationThresholdTextField = new javax.swing.JTextField(); - orientationThresholdButton = new javax.swing.JButton(); - activateContinuousPanel = new javax.swing.JPanel(); - accelerationThresholdTextField = new javax.swing.JTextField(); - accelerationThresholdButton = new javax.swing.JButton(); - deactivateContinuousPanel = new javax.swing.JPanel(); - getStatusButton = new javax.swing.JButton(); - batteryText = new javax.swing.JLabel(); - batteryLevelText = new javax.swing.JLabel(); - ledsPanel = new javax.swing.JPanel(); - toggleSensorBarPositionButton = new javax.swing.JButton(); - alphaSmoothingPanel = new javax.swing.JPanel(); - toggleScreenAspectRatioButton = new javax.swing.JButton(); - orientationThresholdPanel = new javax.swing.JPanel(); - xLabel = new javax.swing.JLabel(); - xResolutionTextField = new javax.swing.JTextField(); - yLabel = new javax.swing.JLabel(); - yResolutionTextField = new javax.swing.JTextField(); - setVirtualResolutionButton = new javax.swing.JButton(); - accelerationThresholdPanel = new javax.swing.JPanel(); - mouseIRControlButton = new javax.swing.JButton(); - batteryPanel = new javax.swing.JPanel(); - expansionText = new javax.swing.JLabel(); - messagesPanel = new javax.swing.JPanel(); - messageLabelText = new javax.swing.JLabel(); - messageText = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("WiiuseJ Test GUI"); - setName("WiiuseJ Test GUI"); // NOI18N - - leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - irViewPanel.setBackground(new java.awt.Color(0, 0, 0)); - irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 2, true), "IR View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, 51))); - - javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(irViewPanel); - irViewPanel.setLayout(irViewPanelLayout); - irViewPanelLayout.setHorizontalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 272, Short.MAX_VALUE) - ); - irViewPanelLayout.setVerticalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 299, Short.MAX_VALUE) - ); - - javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(motionSensingPanel); - motionSensingPanel.setLayout(motionSensingPanelLayout); - motionSensingPanelLayout.setHorizontalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - motionSensingPanelLayout.setVerticalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Orientation", motionSensingPanel); - - javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel); - gForcePanel.setLayout(gForcePanelLayout); - gForcePanelLayout.setHorizontalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - gForcePanelLayout.setVerticalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("GForce", gForcePanel); - - javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(accelerationPanel); - accelerationPanel.setLayout(accelerationPanelLayout); - accelerationPanelLayout.setHorizontalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - accelerationPanelLayout.setVerticalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Raw Acceleration", accelerationPanel); - - javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel); - leftPanel.setLayout(leftPanelLayout); - leftPanelLayout.setHorizontalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE) - ); - leftPanelLayout.setVerticalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup() - .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(irViewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation"); - - rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.LINE_AXIS)); - - fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767)); - fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setPreferredSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setRequestFocusEnabled(false); - fixedWiimotePanel.setLayout(null); - - buttonsPanel.setMaximumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setMinimumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setOpaque(false); - buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484)); - - javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(buttonsPanel); - buttonsPanel.setLayout(buttonsPanelLayout); - buttonsPanelLayout.setHorizontalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 120, Short.MAX_VALUE) - ); - buttonsPanelLayout.setVerticalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 484, Short.MAX_VALUE) - ); - - fixedWiimotePanel.add(buttonsPanel); - buttonsPanel.setBounds(0, 0, 120, 484); - - rightPanel.add(fixedWiimotePanel); - - controlsPanel.setMinimumSize(new java.awt.Dimension(100, 264)); - controlsPanel.setPreferredSize(new java.awt.Dimension(190, 264)); - controlsPanel.setLayout(new java.awt.GridLayout(16, 1)); - - toggleRumbleButton.setText("Activate Rumble"); - toggleRumbleButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleRumbleButtonMousePressed(evt); - } - }); - activateRumblePanel.add(toggleRumbleButton); - - controlsPanel.add(activateRumblePanel); - - toggleIRTrackingButton.setText("Activate IR Tracking"); - toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleIRTrackingButtonMousePressed(evt); - } - }); - deactivateRumblePanel.add(toggleIRTrackingButton); - - controlsPanel.add(deactivateRumblePanel); - - toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking"); - toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleMotionSensingTrackingButtonMousePressed(evt); - } - }); - activateIRtrackingPanel.add(toggleMotionSensingTrackingButton); - - controlsPanel.add(activateIRtrackingPanel); - - toggleSmoothingButton.setText("Activate Smoothing"); - toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSmoothingButtonMousePressed(evt); - } - }); - deactivateIRTrackingPanel.add(toggleSmoothingButton); - - controlsPanel.add(deactivateIRTrackingPanel); - - toggleContinuousButton.setText("Activate Continuous"); - toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleContinuousButtonMousePressed(evt); - } - }); - activateMotionSensingTrackingPanel.add(toggleContinuousButton); - - controlsPanel.add(activateMotionSensingTrackingPanel); - - led1Button.setText("Led1"); - led1Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led1ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led1Button); - - led2Button.setText("Led2"); - led2Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led2ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led2Button); - - led3Button.setText("Led3"); - led3Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led3ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led3Button); - - led4Button.setText("Led4"); - led4Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led4ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led4Button); - - setLedsButton.setText("Set leds"); - setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setLedsButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(setLedsButton); - - controlsPanel.add(deactivateMotionSensingTrackingPanel); - - alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateSmoothingPanel.add(alphaSmoothingTextField); - - alphaSmoothingButton.setText("Set alpha smoothing"); - alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - alphaSmoothingButtonMousePressed(evt); - } - }); - activateSmoothingPanel.add(alphaSmoothingButton); - - controlsPanel.add(activateSmoothingPanel); - - orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - deactivateSmoothingPanel.add(orientationThresholdTextField); - - orientationThresholdButton.setText("Set orientation threshold"); - orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - orientationThresholdButtonMousePressed(evt); - } - }); - deactivateSmoothingPanel.add(orientationThresholdButton); - - controlsPanel.add(deactivateSmoothingPanel); - - accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateContinuousPanel.add(accelerationThresholdTextField); - - accelerationThresholdButton.setText("Set acceleration threshold"); - accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - accelerationThresholdButtonMousePressed(evt); - } - }); - activateContinuousPanel.add(accelerationThresholdButton); - - controlsPanel.add(activateContinuousPanel); - - getStatusButton.setText("Get status"); - getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - getStatusButtonMousePressed(evt); - } - }); - deactivateContinuousPanel.add(getStatusButton); - - batteryText.setFont(new java.awt.Font("Tahoma", 0, 14)); - batteryText.setText("Battery level :"); - deactivateContinuousPanel.add(batteryText); - - batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14)); - batteryLevelText.setText(" %"); - deactivateContinuousPanel.add(batteryLevelText); - - controlsPanel.add(deactivateContinuousPanel); - - toggleSensorBarPositionButton.setText("Set sensor bar above"); - toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSensorBarPositionButtonMousePressed(evt); - } - }); - ledsPanel.add(toggleSensorBarPositionButton); - - controlsPanel.add(ledsPanel); - - toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); - toggleScreenAspectRatioButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleScreenAspectRatioButtonMousePressed(evt); - } - }); - alphaSmoothingPanel.add(toggleScreenAspectRatioButton); - - controlsPanel.add(alphaSmoothingPanel); - - xLabel.setText("X"); - orientationThresholdPanel.add(xLabel); - - xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(xResolutionTextField); - - yLabel.setText("Y"); - orientationThresholdPanel.add(yLabel); - - yResolutionTextField.setFocusTraversalPolicyProvider(true); - yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(yResolutionTextField); - - setVirtualResolutionButton.setText("Set virtual resolution"); - setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setVirtualResolutionButtonMousePressed(evt); - } - }); - orientationThresholdPanel.add(setVirtualResolutionButton); - - controlsPanel.add(orientationThresholdPanel); - - mouseIRControlButton.setText("Start infrared mouse control"); - mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - mouseIRControlButtonMousePressed(evt); - } - }); - accelerationThresholdPanel.add(mouseIRControlButton); - - controlsPanel.add(accelerationThresholdPanel); - - expansionText.setText("No expansion connected"); - batteryPanel.add(expansionText); - - controlsPanel.add(batteryPanel); - - messageLabelText.setFont(new java.awt.Font("Tahoma", 0, 14)); - messageLabelText.setText("Message : "); - messagesPanel.add(messageLabelText); - - messageText.setFont(new java.awt.Font("Arial", 0, 14)); - messageText.setText("None"); - messagesPanel.add(messageText); - - controlsPanel.add(messagesPanel); - - rightPanel.add(controlsPanel); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE) - ); - - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - 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 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 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 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 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 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 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 getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_getStatusButtonMousePressed - wiimote.getStatus(); - statusMotionRequested = true; - statusIRRequested = true; - }//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 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 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 - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel accelerationPanel; - private javax.swing.JButton accelerationThresholdButton; - private javax.swing.JPanel accelerationThresholdPanel; - private javax.swing.JTextField accelerationThresholdTextField; - private javax.swing.JPanel activateContinuousPanel; - private javax.swing.JPanel activateIRtrackingPanel; - private javax.swing.JPanel activateMotionSensingTrackingPanel; - private javax.swing.JPanel activateRumblePanel; - private javax.swing.JPanel activateSmoothingPanel; - private javax.swing.JButton alphaSmoothingButton; - private javax.swing.JPanel alphaSmoothingPanel; - private javax.swing.JTextField alphaSmoothingTextField; - private javax.swing.JLabel batteryLevelText; - private javax.swing.JPanel batteryPanel; - private javax.swing.JLabel batteryText; - private javax.swing.JPanel buttonsPanel; - private javax.swing.JPanel controlsPanel; - private javax.swing.JPanel deactivateContinuousPanel; - private javax.swing.JPanel deactivateIRTrackingPanel; - private javax.swing.JPanel deactivateMotionSensingTrackingPanel; - private javax.swing.JPanel deactivateRumblePanel; - private javax.swing.JPanel deactivateSmoothingPanel; - private javax.swing.JLabel expansionText; - private javax.swing.JPanel fixedWiimotePanel; - private javax.swing.JPanel gForcePanel; - private javax.swing.JButton getStatusButton; - private javax.swing.JPanel irViewPanel; - private javax.swing.JTabbedPane jTabbedPane1; - private javax.swing.JButton led1Button; - private javax.swing.JButton led2Button; - private javax.swing.JButton led3Button; - private javax.swing.JButton led4Button; - private javax.swing.JPanel ledsPanel; - private javax.swing.JPanel leftPanel; - private javax.swing.JLabel messageLabelText; - private javax.swing.JLabel messageText; - private javax.swing.JPanel messagesPanel; - private javax.swing.JPanel motionSensingPanel; - private javax.swing.JButton mouseIRControlButton; - private javax.swing.JButton orientationThresholdButton; - private javax.swing.JPanel orientationThresholdPanel; - private javax.swing.JTextField orientationThresholdTextField; - private javax.swing.JPanel rightPanel; - private javax.swing.JButton setLedsButton; - private javax.swing.JButton setVirtualResolutionButton; - private javax.swing.JButton toggleContinuousButton; - private javax.swing.JButton toggleIRTrackingButton; - private javax.swing.JButton toggleMotionSensingTrackingButton; - private javax.swing.JButton toggleRumbleButton; - private javax.swing.JButton toggleScreenAspectRatioButton; - private javax.swing.JButton toggleSensorBarPositionButton; - private javax.swing.JButton toggleSmoothingButton; - private javax.swing.JLabel xLabel; - private javax.swing.JTextField xResolutionTextField; - private javax.swing.JLabel yLabel; - private javax.swing.JTextField yResolutionTextField; - // End of variables declaration//GEN-END:variables -} diff --git a/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java deleted file mode 100644 index 0403255..0000000 --- a/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.RawAcceleration; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch raw acceleration values from a MotionSensingEvent. - * @author guiguito - */ -public class AccelerationPanel extends javax.swing.JPanel implements 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(); - - /** Creates new form AccelerationPanel */ - public AccelerationPanel() { - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - int yLine = getHeight() - 25; - - g2.setPaint(lineColor); - g2.drawLine(0, yLine, getWidth(), yLine); - - 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; - } - - //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); - } - - /** - * 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(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getRawAcceleration()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java deleted file mode 100644 index 2a4a48f..0000000 --- a/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.Toolkit; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what buttons are pressed. - * It displays the result of last ButtonsEvent. - * @author guiguito - */ -public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener { - - private Image mImage;//image for double buffering - private Image wiimoteImage;//image for double buffering - private ButtonsEvent buttons; - private Color pressedColor = Color.RED; - private Color heldColor = Color.ORANGE; - private Color releasedColor = Color.YELLOW; - private Shape shape; - - /** - * 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); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - 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"); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - //offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw buttons pushed - g2.drawImage(wiimoteImage, 0, 0, this); - g2.setTransform(new AffineTransform()); - - if (buttons != null) { - /* button ONE */ - if (buttons.isButtonOneJustPressed()) { - drawFunction(g2,pressedColor,53,353); - } - if (buttons.isButtonOneHeld()) { - drawFunction(g2,heldColor,53,353); - } - if (buttons.isButtonOneJustReleased()) { - drawFunction(g2, releasedColor, 53, 353); - } - - /* button TWO */ - if (buttons.isButtonTwoJustPressed()) { - drawFunction(g2,pressedColor,53,395); - } - if (buttons.isButtonTwoHeld()) { - drawFunction(g2,heldColor,53,395); - } - if (buttons.isButtonTwoJustReleased()) { - drawFunction(g2,releasedColor,53,395); - } - - /* button A */ - if (buttons.isButtonAJustPressed()) { - drawFunction(g2,pressedColor,53,150); - } - if (buttons.isButtonAHeld()) { - drawFunction(g2,heldColor,53,150); - } - if (buttons.isButtonAJustReleased()) { - drawFunction(g2,releasedColor,53,150); - } - - /* button B */ - if (buttons.isButtonBJustPressed()) { - drawFunction(g2,pressedColor,16,149); - } - if (buttons.isButtonBHeld()) { - drawFunction(g2,heldColor,16,149); - } - if (buttons.isButtonBJustReleased()) { - drawFunction(g2,releasedColor,16,149); - } - - /* button LEFT */ - if (buttons.isButtonLeftJustPressed()) { - drawFunction(g2,pressedColor,33,77); - } - if (buttons.isButtonLeftHeld()) { - drawFunction(g2,heldColor,33,77); - } - if (buttons.isButtonLeftJustReleased()) { - drawFunction(g2,releasedColor,33,77); - } - - /* button RIGHT */ - if (buttons.isButtonRightJustPressed()) { - drawFunction(g2,pressedColor,73,77); - } - if (buttons.isButtonRightHeld()) { - drawFunction(g2,heldColor,73,77); - } - if (buttons.isButtonRightJustReleased()) { - drawFunction(g2,releasedColor,73,77); - } - - /* button UP */ - if (buttons.isButtonUpJustPressed()) { - drawFunction(g2,pressedColor,54,60); - } - if (buttons.isButtonUpHeld()) { - drawFunction(g2,heldColor,54,60); - } - if (buttons.isButtonUpJustReleased()) { - drawFunction(g2,releasedColor,54,60); - } - - /* button DOWN */ - if (buttons.isButtonDownJustPressed()) { - drawFunction(g2,pressedColor,54,97); - } - if (buttons.isButtonDownHeld()) { - drawFunction(g2,heldColor,54,97); - } - if (buttons.isButtonDownJustReleased()) { - drawFunction(g2,releasedColor,54,97); - } - - /* button MINUS */ - if (buttons.isButtonMinusJustPressed()) { - drawFunction(g2,pressedColor,20,230); - } - if (buttons.isButtonMinusHeld()) { - drawFunction(g2,heldColor,20,230); - } - if (buttons.isButtonMinusJustReleased()) { - drawFunction(g2,releasedColor,20,230); - } - - /* button PLUS */ - if (buttons.isButtonPlusJustPressed()) { - drawFunction(g2,pressedColor,86,230); - } - if (buttons.isButtonPlusHeld()) { - drawFunction(g2,heldColor,86,230); - } - if (buttons.isButtonPlusJustReleased()) { - drawFunction(g2,releasedColor,86,230); - } - - /* button HOME */ - if (buttons.isButtonHomeJustPressed()) { - drawFunction(g2,pressedColor,53,230); - } - if (buttons.isButtonHomeHeld()) { - drawFunction(g2,heldColor,53,230); - } - if (buttons.isButtonHomeJustReleased()) { - drawFunction(g2,releasedColor,53,230); - } - - buttons = null; - } - - - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * Function used to factorize code. - * @param g2 where to draw a shape. - * @param col color to use. - * @param x x coordinates. - * @param y y coordinates. - */ - private void drawFunction(Graphics2D g2, Color col, int x, int y) { - g2.setPaint(col); - g2.translate(x, y); - g2.draw(shape); - g2.fill(shape); - g2.setTransform(new AffineTransform()); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); - buttons = arg0; - repaint(); - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - 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() { - - 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/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java b/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java deleted file mode 100644 index 9802688..0000000 --- a/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.GForce; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch gravity force values from a MotionSensingEvent. - * @author guiguito - */ -public class GForcePanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor of the AccelerationPanel. - */ - public GForcePanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * @param bgColor background color. - * @param xxColor color of the acceleration on X axis. - * @param yyColor color of the acceleration on Y axis. - * @param zzColor color of the acceleration on Z axis. - * @param lColor line color. - */ - public GForcePanel(Color bgColor, Color xxColor, Color yyColor, Color zzColor, Color lColor) { - backgroundColor = bgColor; - xColor = xxColor; - yColor = yyColor; - zColor = zzColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - GForce[] valuesArray = values.toArray(new GForce[0]); - double unit = yMiddleFloat / 5.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - GForce gforce = valuesArray[i]; - //draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * gforce.getX()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - //draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * gforce.getY()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - //draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * gforce.getZ()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } - - //draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("5", 2, 10); - g2.drawString("-5", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getGforce()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java deleted file mode 100644 index 3352e66..0000000 --- a/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what the IR camera of the wiimote sees. - * @author guiguito - */ -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; - - /** - * Default constructor for IR Panel. - * Background color : black. - * IR sources color : yellow. - * Border color of IR sources : blue. - * Shape of the IR sources : circle with a diameter of 10. - */ - public IRPanel() { - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); - initArrays(); - initComponents(); - } - - /** - * Constructor used to parameterize the IR panel. - * @param bgColor color. - * @param ptColor IR sources color. - * @param bdColor border color of IR sources. - * @param sh Shape of the IR sources. - */ - public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { - backgroundColor = bgColor; - color = ptColor; - borderColor = bdColor; - shape = sh; - initArrays(); - initComponents(); - } - - private void initArrays(){ - xCoordinates = new int[MAX_NB_POINTS]; - yCoordinates = new int[MAX_NB_POINTS]; - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw points - int i = 0; - while (xCoordinates[i] != -1 && yCoordinates[i] != -1 && i < nbPoints) { - double x = xCoordinates[i]; - double y = yCoordinates[i]; - - long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); - long yy = getHeight() - Math.round((double) getHeight() * y / 768.0); - g2.translate(xx, yy); - - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(color); - g2.fill(shape); - - g2.setTransform(new AffineTransform()); - i++; - } - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - repaint(); - } - - public void onIrEvent(IREvent arg0) { - //transfer points - wiiusej.values.IRSource[] points = arg0.getIRPoints(); - nbPoints = points.length; - for (int i = 0; i < points.length; i++) { - xCoordinates[i] = (int) points[i].getRx(); - yCoordinates[i] = (int) points[i].getRy(); - } - for (int i = points.length; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - - //redraw panel - repaint(); - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void 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(); - } - - /** 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 -} diff --git a/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java deleted file mode 100644 index b50a2ce..0000000 --- a/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.Orientation; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch orientation values from a MotionSensingEvent. - * @author guiguito - */ -public class OrientationPanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor. - * Background color : White. - * Roll color : Red. - * Pitch color : Green. - * Yaw color : Blue. - */ - public OrientationPanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the OrientationPanel. - * @param bgColor background color. - * @param rColor roll color. - * @param pColor pitch color. - * @param yColor yaw color. - * @param lColor line color. - */ - public OrientationPanel(Color bgColor, Color rColor, Color pColor, Color yColor, Color lColor) { - backgroundColor = bgColor; - rollColor = rColor; - pitchColor = pColor; - yawColor = yColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - Orientation[] valuesArray = values.toArray(new Orientation[0]); - double unit = yMiddleFloat / 180.0; - int previousRoll = 0; - int previousPitch = 0; - int previousYaw = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - Orientation orientation = valuesArray[i]; - //draw roll - g2.setPaint(rollColor); - int yDelta = (int) Math.round(unit * orientation.getRoll()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousRoll, i, y); - g2.setTransform(new AffineTransform()); - previousRoll = y; - //draw pitch - g2.setPaint(pitchColor); - yDelta = (int) Math.round(unit * orientation.getPitch()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousPitch, i, y); - g2.setTransform(new AffineTransform()); - previousPitch = y; - //draw yaw - g2.setPaint(yawColor); - yDelta = (int) Math.round(unit * orientation.getYaw()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousYaw, i, y); - g2.setTransform(new AffineTransform()); - previousYaw = y; - } - - //draw legend - g2.setPaint(rollColor); - g2.drawLine(5, getHeight()-10, 25, getHeight()-10); - g2.setPaint(pitchColor); - g2.drawLine(60, getHeight()-10, 80, getHeight()-10); - g2.setPaint(yawColor); - g2.drawLine(120, getHeight()-10, 140, getHeight()-10); - - g2.setPaint(lineColor); - g2.drawString("Roll", 30, getHeight()-5); - g2.drawString("Pitch", 85, getHeight()-5); - g2.drawString("Yaw", 145, getHeight()-5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("180", 2, 10); - g2.drawString("-180", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getOrientation()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11/src/wiiusej/values/GForce.java b/WiiUseJ_0.11/src/wiiusej/values/GForce.java deleted file mode 100644 index 9732121..0000000 --- a/WiiUseJ_0.11/src/wiiusej/values/GForce.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents gravity force on each axis. - * @author guiguito - */ -public class GForce { - - private float x; - private float y; - private float z; - - /** - * 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; - } - - /** - * @return the x - */ - public float getX() { - return x; - } - - /** - * @return the y - */ - public float getY() { - return y; - } - - /** - * @return the z - */ - public float getZ() { - return z; - } - - @Override - public String toString() { - return "Gravity force : ("+x+", "+y+","+z+")"; - } -} diff --git a/WiiUseJ_0.11/src/wiiusej/values/IRSource.java b/WiiUseJ_0.11/src/wiiusej/values/IRSource.java deleted file mode 100644 index 7caef55..0000000 --- a/WiiUseJ_0.11/src/wiiusej/values/IRSource.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class used for IR sources. - * @author guiguito - */ -public class IRSource{ - - 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; - } - - - /** - * 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 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 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+")"; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/values/Orientation.java b/WiiUseJ_0.11/src/wiiusej/values/Orientation.java deleted file mode 100644 index 4c4f741..0000000 --- a/WiiUseJ_0.11/src/wiiusej/values/Orientation.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class that represents the orientation of the wiimote. - * @author guiguito - */ -public class Orientation { - - private float roll; - private float pitch; - private float yaw; - - /** - * Default constructor. - */ - public Orientation(){ - roll = 0; - pitch = 0; - yaw = 0; - } - - /** - * Contructor with raw, pitch , yaw. - * @param r raw - * @param p pitch - * @param y yaw - */ - public Orientation(float r, float p, float y){ - roll = r; - pitch = p; - yaw = y; - } - - /** - * @return the roll - */ - public float getRoll() { - return roll; - } - - /** - * @return the pitch - */ - public float getPitch() { - return pitch; - } - - /** - * @return the yaw - */ - public float getYaw() { - return yaw; - } - - @Override - public String toString() { - return "Orientation : (roll: "+roll+", pitch: "+pitch+", yaw: "+yaw+")"; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java b/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java deleted file mode 100644 index 903a51c..0000000 --- a/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents raw acceleration on each axis. - * @author guiguito - */ -public class RawAcceleration { - - private short x; - private short y; - private short z; - - /** - * 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; - } - - /** - * @return the x - */ - public short getX() { - return x; - } - /** - * @return the y - */ - public short getY() { - return y; - } - - /** - * @return the z - */ - public short getZ() { - return z; - } - - @Override - public String toString() { - return "Raw acceleration : ("+x+", "+y+","+z+")"; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java deleted file mode 100644 index ce78551..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class which represents a buttons event. - * @author guiguito - */ -public class ButtonsEvent extends WiimoteEvent{ - - /* 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 */ - 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); - } - - /** - * 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 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; - } - - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ - - private boolean buttonTest(short buttonBitsDefinition, short buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } - - private boolean isButtonJustPressed(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } - - private boolean isButtonJustReleased(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } - - private boolean isButtonHeld(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } - - private boolean isButtonPressed(short buttonBitsDefinition) { - return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition); - } - /* Button ONE */ - - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOnePressed() { - return isButtonPressed(WIIMOTE_BUTTON_ONE); - } - - /* Button TWO */ - - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoPressed() { - return isButtonPressed(WIIMOTE_BUTTON_TWO); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAPressed() { - return isButtonPressed(WIIMOTE_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBPressed() { - return isButtonPressed(WIIMOTE_BUTTON_B); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftPressed() { - return isButtonPressed(WIIMOTE_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightPressed() { - return isButtonPressed(WIIMOTE_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpPressed() { - return isButtonPressed(WIIMOTE_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownPressed() { - return isButtonPressed(WIIMOTE_BUTTON_DOWN); - } - - /* Button - */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_MINUS); - } - - /* Button + */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_PLUS); - } - - /* Button HOME */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomePressed() { - return isButtonPressed(WIIMOTE_BUTTON_HOME); - } - - @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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/DisconnectionEvent.java deleted file mode 100644 index 341b626..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/DisconnectionEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class representing a disconnection event. - * @author guiguito - */ -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); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; - - return out; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java deleted file mode 100644 index 5c83d78..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java +++ /dev/null @@ -1,241 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class is used to gather events during a call to the Wiiuse API. - * - * @author guiguito - */ -public class EventsGatherer { - - private WiiUseApiEvent[] events; - private int index = 0; - private GenericEvent 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]; - } - - /** - * 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 GenericEvent(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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, - yOffset, sensorBarPostion, screenAsPectRatio); - - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - if (genericEvent != null) { - genericEvent.setMotionSensingEvent(orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, - ya, x, y, z, xx, yy, zz); - } - } - - /** - * 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 DisconnectionEvent to the gatherer. - * - * @param id - * id of the wiimote - */ - public void addDisconnectionEvent(int id) { - DisconnectionEvent evt = new DisconnectionEvent(id); - addEvent(evt); - } - - /** - * Return an array containing the events. - * - * @return events received - */ - public WiiUseApiEvent[] getEvents() { - return java.util.Arrays.copyOfRange(events, 0, index); - } - - /** - * 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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java deleted file mode 100644 index e8ea39b..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class that is a bean to be filled by the wiiuse API. - * - * @author guiguito - */ -public class GenericEvent extends WiiUseApiEvent { - - ButtonsEvent buttonsEvent = null; - IREvent infraredEvent = null; - MotionSensingEvent motionSensingEvent = null; - - /** - * Construct the Wiimote setting up the id. - * - * @param id - * the Wiimote id - */ - public GenericEvent(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 GenericEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, WiiUseApiEvent.GENERIC_EVENT); - buttonsEvent = new ButtonsEvent(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 a motion sensing Event. - * - * @return TRUE if there is a motion sensing event. - */ - public boolean isThereMotionSensingEvent() { - return motionSensingEvent != null; - } - - /** - * Get buttons event. - * - * @return the buttons event. - */ - public ButtonsEvent getButtonsEvent() { - return buttonsEvent; - } - - /** - * Get IR event. - * - * @return the IR event if there is one or null. - */ - public IREvent getIREvent() { - return infraredEvent; - } - - /** - * Get motion sensing event. - * - * @return the motion sensing event if there is one or null. - */ - public MotionSensingEvent getMotionSensingEvent() { - return motionSensingEvent; - } - - /** - * 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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - if (infraredEvent == null) { - infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, - yVRes, xOffset, yOffset, sensorBarPostion, - screenAsPectRatio); - } - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - motionSensingEvent = new MotionSensingEvent(getWiimoteId(), - orientationThreshold, accelerationThreshold, smoothingState, - alphaSmooth, r, p, ya, x, y, z, xx, yy, zz); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GENERIC EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - - out += buttonsEvent; - - 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"; - } - - return out; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java deleted file mode 100644 index 6007e97..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.IRSource; - -/** - * Class which represents an IR event. - * - * @author guiguito - */ -public class IREvent extends WiimoteEvent { - - /* IR Tracking */ - private IRSource[] IRPoints; - private short indexPoints = 0; - private int x; - private int y; - private int 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; - - 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 - - /** - * 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. - */ - public IREvent(int id, int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - 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; - IRPoints = new IRSource[NB_POINTS]; - } - - /** - * Get list of IR points. - * - * @return the list of 2D points - */ - public IRSource[] getIRPoints() { - return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints); - } - - /** - * 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 Y coordinate. - * - * @return the y - */ - public int getY() { - return y; - } - - /** - * Return calculated distance. - * - * @return the z - */ - public int getZ() { - return z; - } - - /** - * 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 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 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 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 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 aspect ratio of the screen. - * - * @return the screenAsPectRatio - */ - public short getScreenAsPectRatio() { - return screenAsPectRatio; - } - - @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 distance : " + z + "\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"; - 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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java deleted file mode 100644 index 6ec7712..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.GForce; -import wiiusej.values.Orientation; -import wiiusej.values.RawAcceleration; - -/** - * Class which represents a motion sensing event. - * - * @author guiguito - */ -public class MotionSensingEvent extends WiimoteEvent { - - /* 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; - - /** - * 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 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 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, x, y, z, xx, yy, zz); - } - - /** - * Set orientation, gravity force and raw acceleration. - * - * @param r - * roll - * @param p - * pitch - * @param ya - * yaw - * @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 x, - float y, float z, short xx, short yy, short zz) { - this.orientation = new Orientation(r, p, ya); - this.gforce = new GForce(x, y, z); - this.acceleration = new RawAcceleration(xx, yy, zz); - } - - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * 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 orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } - - /** - * Get acceleration threshold. - * - * @return the accelerationThreshold - */ - public int getAccelerationThreshold() { - return accelerationThreshold; - } - - /** - * 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; - } - - @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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java deleted file mode 100644 index 7a365fc..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class used to represent a status event. This class is used to know what are - * the settings of the wiimote. - * - * @author guiguito - */ -public class StatusEvent extends WiiUseApiEvent { - - private static short WIIMOTE_LED_1 = 1; - private static short WIIMOTE_LED_2 = 2; - private static short WIIMOTE_LED_3 = 4; - private static short WIIMOTE_LED_4 = 8; - - /* 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; - - /* Status variables */ - private boolean connected = false; - - private float batteryLevel = -1; - - private short leds = 0; - - private boolean isSpeakerEnabled = false; - - private int attachment = 0; - - private boolean isRumbleActive = false; - - private boolean isContinuousActive = false; - - private boolean isIrActive = 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); - } - - /** - * 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; - } - - /** - * 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 led1 status. - * - * @return true if the led is set. - */ - public boolean isLed1Set() { - if ((leds & WIIMOTE_LED_1) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led2 status. - * - * @return true if the led is set. - */ - public boolean isLed2Set() { - if ((leds & WIIMOTE_LED_2) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led3 status. - * - * @return true if the led is set. - */ - public boolean isLed3Set() { - if ((leds & WIIMOTE_LED_3) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led4 status. - * - * @return true if the led is set. - */ - public boolean isLed4Set() { - if ((leds & WIIMOTE_LED_4) > 0) { - return true; - } else { - return false; - } - } - - /** - * 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 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 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; - } - - @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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java deleted file mode 100644 index 880c632..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class describes the structure of an event from the WiiUse API event. - * - * @author guiguito - */ -public abstract class WiiUseApiEvent extends WiimoteEvent{ - - public static int GENERIC_EVENT = 1; - public static int STATUS_EVENT = 2; - public static int DISCONNECTION_EVENT = 3; - public static int WIIUSE_NUNCHUK_INSERTED = 4; - public static int WIIUSE_NUNCHUK_REMOVED = 5; - public static int WIIUSE_CLASSIC_CTRL_INSERTED = 6; - public static int WIIUSE_CLASSIC_CTRL_REMOVED = 7; - public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 8; - public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 9; - - /* 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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java deleted file mode 100644 index 3f6bb22..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - - - -/** - * This is the interface to implement to listen to events from the wiiuse API. - * - * @author guiguito - */ -public interface WiiUseApiListener extends java.util.EventListener { - - /** - * Method called when a WiiUseApiEvent occurs. - * A WiiUseApiEvent can be : - * - GenericEvent (Storing ButtonsEvent and - * eventually IREvent and MotionSensingEvent) - * - StatusEvent - * - DisconnectionEvent - * @param e - */ - void onWiiUseApiEvent(WiiUseApiEvent e); - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java deleted file mode 100644 index 1504a37..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Abstract mother class representing an event with a wiimote id. - * - * @author guiguito - */ -public abstract class WiimoteEvent { - - /* ID */ - private int wiimoteId = -1; - - /** - * Construct the WiiUseApiEvent setting up the id. - * - * @param id - * the Wiimote id - */ - public WiimoteEvent(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/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java deleted file mode 100644 index 3ea3c05..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This is the interface to implement to listen to events from wiimotes. - * The differents methods are called in this order : - * onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent. - * - * @author guiguito - */ -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(ButtonsEvent 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 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); - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java deleted file mode 100644 index a003239..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with a float value to pass to wiiuse API. - * - * @author guiguito - */ -public class FloatValueRequest extends WiiUseApiRequest { - - private float floatValue; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public FloatValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * threshold in degrees - */ - public FloatValueRequest(int id, int type, float th) { - super(id, type); - floatValue = th; - } - - /** - * Get the float value. - * @return the float value - */ - public float getFloatValue() { - return floatValue; - } - - /** - * Set the float value. - * @param val the value to set - */ - public void setFloatValue(float val) { - this.floatValue = val; - } - - - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java deleted file mode 100644 index 801093d..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with an int value to pass to wiiuse API. - * - * @author guiguito - */ -public class IntValueRequest extends WiiUseApiRequest { - - private int intValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id - * the id of the wiimote concerned. - */ - public IntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the int value. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * the int value. - */ - public IntValueRequest(int id, int type, int th) { - super(id, type); - intValue = th; - } - - /** - * Get the int value. - * @return the int value - */ - public int getIntValue() { - return intValue; - } - - /** - * Set the int value. - * @param val the value to set - */ - public void setIntValue(int val) { - this.intValue = val; - } - - - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java deleted file mode 100644 index 1a21024..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request to set leds of the wiimote with WiiUse API. - * - * @author guiguito - */ -public class LedsRequest extends wiiusej.wiiuseapirequest.WiiUseApiRequest { - - private boolean led1, led2, led3, led4; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - */ - public LedsRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - * @param l1 - * led1 status. True=ON, False=OFF - * @param l2 - * led2 status. True=ON, False=OFF - * @param l3 - * led3 status. True=ON, False=OFF - * @param l4 - * led4 status. True=ON, False=OFF - */ - public LedsRequest(int id, int type, boolean l1, boolean l2, boolean l3, - boolean l4) { - super(id, type); - led1 = l1; - led2 = l2; - led3 = l3; - led4 = l4; - } - - /** - * @return the led1 - */ - public boolean isLed1() { - return led1; - } - - /** - * @param led1 - * the led1 to set - */ - public void setLed1(boolean led1) { - this.led1 = led1; - } - - /** - * @return the led2 - */ - public boolean isLed2() { - return led2; - } - - /** - * @param led2 - * the led2 to set - */ - public void setLed2(boolean led2) { - this.led2 = led2; - } - - /** - * @return the led3 - */ - public boolean isLed3() { - return led3; - } - - /** - * @param led3 - * the led3 to set - */ - public void setLed3(boolean led3) { - this.led3 = led3; - } - - /** - * @return the led4 - */ - public boolean isLed4() { - return led4; - } - - /** - * @param led4 - * the led4 to set - */ - public void setLed4(boolean led4) { - this.led4 = led4; - } - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java deleted file mode 100644 index 98e907e..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - - -/** - * Represents a request with two int values to pass to wiiuse API. - * - * @author guiguito - */ -public class TwoIntValueRequest extends IntValueRequest { - - private int secondIntValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - */ - public TwoIntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the two int values. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - * @param x first int value. - * @param y second int value. - */ - public TwoIntValueRequest(int id, int type, int x, int y) { - super(id, type, x); - secondIntValue = y; - } - - /** - * Get the second int value. - * @return the secondIntValue - */ - public int getSecondIntValue() { - return secondIntValue; - } - - /** - * Set the second int value. - * @param secondIntValue the secondIntValue to set. - */ - public void setSecondIntValue(int secondIntValue) { - this.secondIntValue = secondIntValue; - } - - - -} diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java deleted file mode 100644 index 1f4525b..0000000 --- a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request we could do to the WiiUse API. - * - * @author guiguito - */ -public class WiiUseApiRequest { - - public static int WIIUSE_STATUS_REQUEST = 1; - public static int WIIUSE_ACTIVATE_SMOOTHING_REQUEST = 2; - public static int WIIUSE_DEACTIVATE_SMOOTHING_REQUEST = -2; - public static int WIIUSE_ACTIVATE_IR_TRACKING_REQUEST = 3; - public static int WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST = -3; - public static int WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST = 4; - public static int WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST = -4; - public static int WIIUSE_CLOSE_CONNECTION_REQUEST = 5; - public static int WIIUSE_ACTIVATE_CONTINUOUS_REQUEST = 6; - public static int WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST = -6; - public static int WIIUSE_ACTIVATE_RUMBLE_REQUEST = 7; - public static int WIIUSE_DEACTIVATE_RUMBLE_REQUEST = -7; - public static int WIIUSE_LEDS_REQUEST = 8; - public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9; - public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10; - public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11; - public static int WIIUSE_RESYNC = 12; - public static int WIIUSE_ASPECT_RATIO_4_3 = 13; - public static int WIIUSE_ASPECT_RATIO_16_9 = 14; - public static int WIIUSE_SENSOR_BAR_ABOVE = 15; - public static int WIIUSE_SENSOR_BAR_BELOW = 16; - public static int WIIUSE_SET_VIRTUAL_RESOLUTION = 17; - - private int wiimoteId = 0; - private int requestType = 0; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public WiiUseApiRequest(int id) { - wiimoteId = id; - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * - */ - public WiiUseApiRequest(int id, int type) { - wiimoteId = id; - requestType = type; - } - - /** - * Get id of the wiimote concerned by this request. - * - * @return id of the wiimote concerned - */ - public int getId() { - return wiimoteId; - } - - /** - * Set id of the wiimote concerned by this request. - * - * @param id - * id fh the wiimote concernet - */ - public void setId(int id) { - wiimoteId = id; - } - - /** - * Get the request type. - * - * @return the requestType - */ - public int getRequestType() { - return requestType; - } - - /** - * Set the request type. - * - * @param requestType - * the requestType to set - */ - public void setRequestType(int requestType) { - this.requestType = requestType; - } - -} diff --git a/WiiUseJ_0.11/wiiuse.dll b/WiiUseJ_0.11/wiiuse.dll deleted file mode 100644 index 6855619..0000000 Binary files a/WiiUseJ_0.11/wiiuse.dll and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/.classpath b/WiiUseJ_0.11ThreadReqeuests/.classpath deleted file mode 100644 index d171cd4..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/WiiUseJ_0.11ThreadReqeuests/.project b/WiiUseJ_0.11ThreadReqeuests/.project deleted file mode 100644 index 9485f4a..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - WiiUseJava - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/WiiUseJ_0.11ThreadReqeuests/README.TXT b/WiiUseJ_0.11ThreadReqeuests/README.TXT deleted file mode 100644 index 268d31d..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/README.TXT +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ - - -WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI. - -WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes. - -Some of the great aspects of this API are : - - * The compatibility which is as large as Wiiuse's API compatibility - - * Cross-platform : Windows and linux (like Wiiuse) - - * Easy to use - - -WiiuseJ is made by Guilhem Duché : guiguito1@hotmail.com. -You can contact me if you need more information. - -Go to : http://wiiusej.googlecode.com/ for further documentations. - - - diff --git a/WiiUseJ_0.11ThreadReqeuests/WiiUseJ.dll b/WiiUseJ_0.11ThreadReqeuests/WiiUseJ.dll deleted file mode 100644 index 6999b85..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/WiiUseJ.dll and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/img/wiimote.png b/WiiUseJ_0.11ThreadReqeuests/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/libWiiuseJ.so b/WiiUseJ_0.11ThreadReqeuests/libWiiuseJ.so deleted file mode 100644 index 47ab1f2..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/libWiiuseJ.so and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/libwiiuse.so b/WiiUseJ_0.11ThreadReqeuests/libwiiuse.so deleted file mode 100644 index 2f9247b..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/libwiiuse.so and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/src/img/wiimote.png b/WiiUseJ_0.11ThreadReqeuests/src/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/src/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApi.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApi.java deleted file mode 100644 index 3f169e6..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApi.java +++ /dev/null @@ -1,265 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import wiiusej.wiiuseapievents.EventsGatherer; - -/** - * Singleton used to manipulate WiiUse Api. - * - * @author guiguito - */ -public class WiiUseApi { - - static { - System.loadLibrary("WiiuseJ"); - } - - private static WiiUseApi instance = new WiiUseApi(); - - /** - * Get the only instance of WiiUseApi. - * - * @return the only instace of WiiUseApi. - */ - static WiiUseApi getInstance() { - return instance; - } - - /** - * Try to connect to 2 wiimotes. Make them rumble to show they are - * connected. - * - * @param nb - * number of wiimotes to connect - * @param rumble - * make the connected wiimotes rumble - * @return 0 if there is an error otherwise it returns the number of - * wiimotes connected. - */ - native int doConnections(int nb, boolean rumble); - - /** - * Close connection to the wiimote with the given id. - * - */ - native void closeConnection(int id); - - /** - * Shutdown Wiiuse API. - */ - native void shutdownApi(); - - /** - * Activate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateRumble(int id); - - /** - * Deactivate rumble on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void deactivateRumble(int id); - - /** - * Activate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateIRTracking(int id); - - /** - * Deactivate IR Tracking on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void deactivateIRTracking(int id); - - /** - * Activate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - native void activateMotionSensing(int id); - - /** - * Deactivate motion sensing on the wiimote with the given id. - * - * @param id - * the id of the wiimote. - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - native void activateSmoothing(int id); - - /** - * Make the the accelerometers give raw results. - * - * @param id - * the id of the wiimote concerned - */ - 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 - */ - native void activateContinuous(int id); - - /** - * Make the wiimote generate an event only when there is one. - * - * @param id - * the id of the wiimote concerned - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - 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. - */ - native void getStatus(int id); - - /** - * 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiManager.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiManager.java deleted file mode 100644 index 4f273b4..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiManager.java +++ /dev/null @@ -1,491 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.EventsGatherer; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapirequest.FloatValueRequest; -import wiiusej.wiiuseapirequest.IntValueRequest; -import wiiusej.wiiuseapirequest.LedsRequest; -import wiiusej.wiiuseapirequest.TwoIntValueRequest; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that manages the use of Wiiuse API. - * - * @author guiguito - */ -public class WiiUseApiManager extends Thread { - - private static WiiUseApiManager instance = new WiiUseApiManager(); - - private final EventListenerList listeners = new EventListenerList(); - - private Wiimote[] wiimotes; - - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - - private int connected = -1; - - private AtomicBoolean running = new AtomicBoolean(false); - - private WiiUseApiRequestsManager requestManager = WiiUseApiRequestsManager - .getInstance(); - - 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 synchronized static Wiimote[] getWiimotes(int nb, boolean rumble) { - WiiUseApiManager manager = getInstance(); - if (manager.connected <= 0 && !manager.running.get()) { - int nbWiimotes = manager.connectWiimotes(nb, rumble); - manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i = 1; i <= nbWiimotes; i++) { - Wiimote wim = new Wiimote(i, manager); - manager.wiimotes[i - 1] = wim; - manager.addWiiUseApiListener(wim); - } - } - - if (manager.connected == 0) { - return new Wiimote[0]; - } - - if (!manager.isAlive()){ - manager.start(); - manager.requestManager.start(); - } - - 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 - * @return 0 if nothing connected or the number of wiimotes connected. - */ - private int connectWiimotes(int nb, boolean rumble) { - if (connected <= 0) { - connected = wiiuse.doConnections(nb, rumble); - 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. - */ - public void closeConnection(int id) { - removeWiiUseApiListener(wiimotes[id - 1]); - wiimotes[id - 1] = null; - connected--; - if (connected == 0) {// stop this thread if there is - // no more wiimotes connected. - //stop thread - shutdown(); - } - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST)); - // System.out.println("Wiimote " + id + " disconnected !"); - } - - /** - * Get the number of wiimotes connected. - * - * @return the number of wiimotes connected. - */ - public int getNbConnectedWiimotes() { - return connected; - } - - /** - * Stop thread and shutdown wiiuse Api. - */ - public void shutdown() { - if (connected > 0) { - for (Wiimote wim : wiimotes) { - if (wim != null) - wim.disconnect(); - } - } - running.set(false); - wiiuse.shutdownApi(); - } - - /** - * Activate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateRumble(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Deactivate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateRumble(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Activate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateIRTRacking(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Deactivate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateIRTRacking(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Activate motion sensing for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateMotionSensing(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Deactivate motion sensing for the wiimoter with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateMotionSensing(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Activate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateSmoothing(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Deactivate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateSmoothing(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Activate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateContinuous(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * Deactivate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote - */ - public void deactivateContinuous(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * 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 - */ - public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) { - requestManager.addRequests(new LedsRequest(id, - WiiUseApiRequest.WIIUSE_LEDS_REQUEST, l1, l2, l3, l4)); - } - - /** - * Set the orientation threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(int id, float th) { - requestManager.addRequests(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST, th)); - } - - /** - * Set the acceleration threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAccelerationThreshold(int id, int th) { - requestManager.addRequests(new IntValueRequest(id, - WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th)); - } - - /** - * Set alpha smoothing for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold - */ - public void setAlphaSmoothing(int id, float th) { - requestManager.addRequests(new FloatValueRequest(id, - WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th)); - } - - /** - * Try to resync with the wiimote by starting a new handshake. - * - * @param id - * id of the wiimote - */ - public void reSync(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_RESYNC)); - } - - /** - * Set screen aspect ratio to 4/3 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio43(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3)); - } - - /** - * Set screen aspect ratio to 16/9 for the given id. - * - * @param id - * id of the wiimote - */ - public void setScreenAspectRatio169(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9)); - } - - /** - * Set the sensor bar to be above the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarAboveScreen(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE)); - } - - /** - * Set the sensor bar to be below the screen. - * - * @param id - * id of the wiimote - */ - public void setSensorBarBelowScreen(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW)); - } - - /** - * 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 - */ - public void setVirtualResolution(int id, int x, int y) { - requestManager.addRequests(new TwoIntValueRequest(id, - WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION, x, y)); - } - - /** - * Get Status for the wiimote for the given id. - * - * @param id - * id of the wiimote - */ - public void getStatus(int id) { - requestManager.addRequests(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_STATUS_REQUEST)); - } - - @Override - public void run() { - - if (connected > 0) { - running.set(true); - - EventsGatherer gather = new EventsGatherer(connected); - - // Start polling and tell the observers when there are Wiimote - // events - while (running.get() && connected > 0) { - - /* Polling */ - synchronized (wiiuse) { - 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 !"); - } - } - - } - - /** - * Add WiiUseApiListener to the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void addWiiUseApiListener(WiiUseApiListener listener) { - listeners.add(WiiUseApiListener.class, listener); - } - - /** - * Remove WiiUseApiListener from the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void removeWiiUseApiListener(WiiUseApiListener listener) { - listeners.remove(WiiUseApiListener.class, listener); - } - - /** - * Get the list of WiiUseApiListeners. - * - * @return the list of WiiUseApiListeners. - */ - public WiiUseApiListener[] getWiiUseApiListeners() { - return listeners.getListeners(WiiUseApiListener.class); - } - - /** - * Notify WiiUseApiListeners that an event occured. - * - * @param evt - * WiimoteEvent occured - */ - private void notifyWiiUseApiListener(WiiUseApiEvent evt) { - for (WiiUseApiListener listener : getWiiUseApiListeners()) { - listener.onWiiUseApiEvent(evt); - } - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiRequestsManager.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiRequestsManager.java deleted file mode 100644 index b3ac993..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/WiiUseApiRequestsManager.java +++ /dev/null @@ -1,162 +0,0 @@ -package wiiusej; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Semaphore; - -import wiiusej.wiiuseapirequest.FloatValueRequest; -import wiiusej.wiiuseapirequest.IntValueRequest; -import wiiusej.wiiuseapirequest.LedsRequest; -import wiiusej.wiiuseapirequest.TwoIntValueRequest; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * This class is thread dedicated to send request to WiiUseApi. It is used only - * (and must be used only) by WiiUseApiManager. - * - * @author guiguito - * - */ -public class WiiUseApiRequestsManager extends Thread { - - //protected Semaphore semaphore = new Semaphore(0); - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - private ConcurrentLinkedQueue requests = new ConcurrentLinkedQueue(); - private static WiiUseApiRequestsManager instance = new WiiUseApiRequestsManager(); - private boolean running = false; - - /** - * Default constructor. - */ - WiiUseApiRequestsManager() { - super(); - } - - public static WiiUseApiRequestsManager getInstance() { - return instance; - } - - public void addRequests(WiiUseApiRequest request) { - requests.add(request); - //semaphore.release(); - synchronized (requests) { - requests.notify(); - } - } - - public void run() { - running = true; - while (running) { - /* deal with requests done to wiiuse API */ - - /* - try { - semaphore.acquire(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - */ - if (requests.size()==0){ - synchronized (requests) { - try { - requests.wait(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - WiiUseApiRequest req = requests.poll(); - if (req != null) {// there is a request for the wiiuse api - int id = req.getId(); - synchronized (wiiuse) {// synchronized on wiiuseApi - if (req.getRequestType() == WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST) { - /* Close connections requests */ - wiiuse.closeConnection(id); - if (WiiUseApiManager.getInstance() - .getNbConnectedWiimotes() <= 0) { - this.shutdown(); - } - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) { - /* Status requests */ - wiiuse.getStatus(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST) { - /* Activate Rumble requests */ - wiiuse.activateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST) { - /* Deactivate Rumble requests */ - wiiuse.deactivateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST) { - /* Activate IR Tracking requests */ - wiiuse.activateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST) { - /* Deactivate IR Tracking requests */ - wiiuse.deactivateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST) { - /* Activate Motion sensing requests */ - wiiuse.activateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST) { - /* Deactivate Motion sensing requests */ - wiiuse.deactivateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_LEDS_REQUEST) { - /* leds requests */ - LedsRequest reqLed = (LedsRequest) req; - wiiuse.setLeds(id, reqLed.isLed1(), reqLed.isLed2(), - reqLed.isLed3(), reqLed.isLed4()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST) { - /* Activate smoothing requests */ - wiiuse.activateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST) { - /* Deactivate smoothing requests */ - wiiuse.deactivateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST) { - /* Activate continuous requests */ - wiiuse.activateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST) { - /* Deactivate continuous requests */ - wiiuse.deactivateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST) { - /* set orientation threshold request */ - wiiuse.setOrientThreshold(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) { - /* set acceleration threshold request */ - wiiuse.setAccelThreshold(req.getId(), - ((IntValueRequest) req).getIntValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) { - /* set alpha smoothing request */ - wiiuse.setAlphaSmoothing(req.getId(), - ((FloatValueRequest) req).getFloatValue()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) { - /* set resync request */ - wiiuse.reSync(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3) { - /* set screen aspect ratio to 4/3 */ - wiiuse.setScreenRatio43(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9) { - /* set screen aspect ratio to 16/9 */ - wiiuse.setScreenRatio169(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarAboveScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW) { - /* set sensor bar above the screen */ - wiiuse.setSensorBarBelowScreen(req.getId()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION) { - /* set virtual resolution */ - wiiuse.setVirtualScreenResolution(req.getId(), - ((TwoIntValueRequest) req).getIntValue(), - ((TwoIntValueRequest) req).getSecondIntValue()); - } else { - System.out.println("Bad request to Wiiuse API !!!!!"); - } - }// end synchronized on wiiuseApi - }//if (req != null) - }//end while(running) - } - - public void shutdown() { - running = false; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/Wiimote.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/Wiimote.java deleted file mode 100644 index f04e66c..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/Wiimote.java +++ /dev/null @@ -1,323 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiuseapievents.WiiUseApiListener; -import wiiusej.wiiuseapievents.WiimoteListener; -import wiiusej.wiiuseapirequest.WiiUseApiRequest; - -/** - * Class that represents a wiimote. - * You can register as an observer of this wiimote to listen events from it. - * You manage it. - * @author guiguito - */ -public class Wiimote implements WiiUseApiListener { - - private int id = -1;//wiimote id - - private EventListenerList listeners = new EventListenerList(); - - 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; - } - - /** - * Disconnect this wiimote. - */ - public void disconnect(){ - deactivateIRTRacking(); - deactivateMotionSensing(); - deactivateRumble(); - manager.closeConnection(id); - } - - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } - - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } - - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } - - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } - - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } - - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } - - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } - - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } - - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(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 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 . - * @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 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 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 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); - } - - /** - * 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); - } - - /** - * 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((GenericEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED - ||e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED - ||e.getEventType() == 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){ - notifyStatusEventListeners((StatusEvent)e); - }else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT){ - notifyDisconnectionEventListeners((DisconnectionEvent)e); - } - } - } - - /** - * 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); - } - - /** - * 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 WiimoteEvent occured - */ - private void notifyWiiMoteEventListeners(GenericEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onButtonsEvent(evt.getButtonsEvent()); - if (evt.isThereIrEvent()){ - listener.onIrEvent(evt.getIREvent()); - } - if (evt.isThereMotionSensingEvent()){ - listener.onMotionSensingEvent(evt.getMotionSensingEvent()); - } - } - } - - /** - * 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 notifyDisconnectionEventListeners(DisconnectionEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onDisconnectionEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : "+id; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/CloseGuiTestCleanly.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/CloseGuiTestCleanly.java deleted file mode 100644 index ae136bf..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/CloseGuiTestCleanly.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * This class is used to close wiiusej cleanly. - * @author guiguito - */ -public class CloseGuiTestCleanly implements WindowListener{ - - Wiimote wiimote; - - - public CloseGuiTestCleanly(Wiimote wim) { - wiimote = wim; - } - - public void windowOpened(WindowEvent e) { - //nothing - } - - public void windowClosing(WindowEvent e) { - WiiUseApiManager.getInstance().shutdown(); - } - - public void windowClosed(WindowEvent e) { - //nothing - } - - public void windowIconified(WindowEvent e) { - //nothing - } - - public void windowDeiconified(WindowEvent e) { - //nothing - } - - public void windowActivated(WindowEvent e) { - //nothing - } - - public void windowDeactivated(WindowEvent e) { - //nothing - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Main.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Main.java deleted file mode 100644 index daaca2a..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Main.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * Main Class to launch WiiuseJ GUI Test. - * @author guiguito - */ -public class Main { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); - if (wiimotes.length>0){ - WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]); - gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); - gui.setVisible(true); - } - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Tests.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Tests.java deleted file mode 100644 index 1a82547..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/Tests.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.values.IRSource; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.GenericEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This class used to test WiiuseJ. - * - * @author guiguito - */ -public class Tests implements WiimoteListener { - - 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 Wiimote wiimote; - - int dump = DISPLAY_EACH_VALUE; - - public Tests(Wiimote wim) { - wiimote = wim; - wiimote.addWiiMoteEventListeners(this); - try { - robot = new Robot(); - } catch (AWTException e) { - e.printStackTrace(); - } - } - - private static int nb = 0; - - public void onButtonsEvent(ButtonsEvent 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 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 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 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 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 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(); - } - - /* 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 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(); - } - - } 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(); - } - - /* 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); - } - - /* 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(); - } - } - - } - - 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); - } - } - - public void onMotionSensingEvent(MotionSensingEvent e) { - /* display motion sensing */ - 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 !!"); - } - - /** - * @param args - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(4, true); - if (wiimotes.length > 0) { - System.out.println(wiimotes[0]); - Tests tests = 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); - - } -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/WiiuseJGuiTest.java deleted file mode 100644 index 8bac8ae..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/test/WiiuseJGuiTest.java +++ /dev/null @@ -1,836 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; -import java.util.logging.Level; -import java.util.logging.Logger; -import wiiusej.utils.IRPanel; -import wiiusej.Wiimote; -import wiiusej.utils.AccelerationPanel; -import wiiusej.utils.GForcePanel; -import wiiusej.utils.ButtonsEventPanel; -import wiiusej.utils.OrientationPanel; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * Gui class to test WiiuseJ. - * @author guiguito - */ -public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListener { - - private Wiimote wiimote; - private Robot robot = null; - private boolean statusMotionRequested = false; - private boolean statusIRRequested = false; - - /** Creates new form WiiuseJGuiTest */ - public WiiuseJGuiTest(Wiimote wiimote) { - initComponents(); - this.wiimote = wiimote; - wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel); - wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel); - wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel); - wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); - wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel); - wiimote.addWiiMoteEventListeners(this); - wiimote.deactivateContinuous(); - wiimote.deactivateSmoothing(); - wiimote.setScreenAspectRatio169(); - wiimote.setSensorBarBelowScreen(); - getStatusButtonMousePressed(null); - this.addWindowListener(new CloseGuiTestCleanly(wiimote)); - } - - public void onButtonsEvent(ButtonsEvent arg0) { - if (robot != null) { - if (arg0.isButtonAPressed()) { - robot.mousePress(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBPressed()) { - robot.mousePress(InputEvent.BUTTON2_MASK); - - } - if (arg0.isButtonOnePressed()) { - robot.mousePress(InputEvent.BUTTON3_MASK); - - } - if (arg0.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_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.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 onMotionSensingEvent(MotionSensingEvent arg0) { - if (statusMotionRequested){//Status requested - accelerationThresholdTextField.setText(""+arg0.getAccelerationThreshold()); - orientationThresholdTextField.setText(""+arg0.getOrientationThreshold()); - alphaSmoothingTextField.setText(""+arg0.getAlphaSmoothing()); - statusMotionRequested = false; - } - } - - public void onStatusEvent(StatusEvent arg0) { - messageText.setText("Status received !"); - batteryLevelText.setText(arg0.getBatteryLevel() + " %"); - led1Button.setEnabled(arg0.isLed1Set()); - led2Button.setEnabled(arg0.isLed2Set()); - led3Button.setEnabled(arg0.isLed3Set()); - led4Button.setEnabled(arg0.isLed4Set()); - //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 !"); - } - - /** 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() { - - leftPanel = new javax.swing.JPanel(); - irViewPanel = new IRPanel(); - jTabbedPane1 = new javax.swing.JTabbedPane(); - motionSensingPanel = new OrientationPanel(); - gForcePanel = new wiiusej.utils.GForcePanel(); - accelerationPanel = new AccelerationPanel(); - rightPanel = new javax.swing.JPanel(); - fixedWiimotePanel = new javax.swing.JPanel(); - buttonsPanel = new ButtonsEventPanel(); - controlsPanel = new javax.swing.JPanel(); - activateRumblePanel = new javax.swing.JPanel(); - toggleRumbleButton = new javax.swing.JButton(); - deactivateRumblePanel = new javax.swing.JPanel(); - toggleIRTrackingButton = new javax.swing.JButton(); - activateIRtrackingPanel = new javax.swing.JPanel(); - toggleMotionSensingTrackingButton = new javax.swing.JButton(); - deactivateIRTrackingPanel = new javax.swing.JPanel(); - toggleSmoothingButton = new javax.swing.JButton(); - activateMotionSensingTrackingPanel = new javax.swing.JPanel(); - toggleContinuousButton = new javax.swing.JButton(); - deactivateMotionSensingTrackingPanel = new javax.swing.JPanel(); - led1Button = new javax.swing.JButton(); - led2Button = new javax.swing.JButton(); - led3Button = new javax.swing.JButton(); - led4Button = new javax.swing.JButton(); - setLedsButton = new javax.swing.JButton(); - activateSmoothingPanel = new javax.swing.JPanel(); - alphaSmoothingTextField = new javax.swing.JTextField(); - alphaSmoothingButton = new javax.swing.JButton(); - deactivateSmoothingPanel = new javax.swing.JPanel(); - orientationThresholdTextField = new javax.swing.JTextField(); - orientationThresholdButton = new javax.swing.JButton(); - activateContinuousPanel = new javax.swing.JPanel(); - accelerationThresholdTextField = new javax.swing.JTextField(); - accelerationThresholdButton = new javax.swing.JButton(); - deactivateContinuousPanel = new javax.swing.JPanel(); - getStatusButton = new javax.swing.JButton(); - batteryText = new javax.swing.JLabel(); - batteryLevelText = new javax.swing.JLabel(); - ledsPanel = new javax.swing.JPanel(); - toggleSensorBarPositionButton = new javax.swing.JButton(); - alphaSmoothingPanel = new javax.swing.JPanel(); - toggleScreenAspectRatioButton = new javax.swing.JButton(); - orientationThresholdPanel = new javax.swing.JPanel(); - xLabel = new javax.swing.JLabel(); - xResolutionTextField = new javax.swing.JTextField(); - yLabel = new javax.swing.JLabel(); - yResolutionTextField = new javax.swing.JTextField(); - setVirtualResolutionButton = new javax.swing.JButton(); - accelerationThresholdPanel = new javax.swing.JPanel(); - mouseIRControlButton = new javax.swing.JButton(); - batteryPanel = new javax.swing.JPanel(); - expansionText = new javax.swing.JLabel(); - messagesPanel = new javax.swing.JPanel(); - messageLabelText = new javax.swing.JLabel(); - messageText = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("WiiuseJ Test GUI"); - setName("WiiuseJ Test GUI"); // NOI18N - - leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - irViewPanel.setBackground(new java.awt.Color(0, 0, 0)); - irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 2, true), "IR View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, 51))); - - javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(irViewPanel); - irViewPanel.setLayout(irViewPanelLayout); - irViewPanelLayout.setHorizontalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 272, Short.MAX_VALUE) - ); - irViewPanelLayout.setVerticalGroup( - irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 299, Short.MAX_VALUE) - ); - - javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(motionSensingPanel); - motionSensingPanel.setLayout(motionSensingPanelLayout); - motionSensingPanelLayout.setHorizontalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - motionSensingPanelLayout.setVerticalGroup( - motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Orientation", motionSensingPanel); - - javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel); - gForcePanel.setLayout(gForcePanelLayout); - gForcePanelLayout.setHorizontalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - gForcePanelLayout.setVerticalGroup( - gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("GForce", gForcePanel); - - javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(accelerationPanel); - accelerationPanel.setLayout(accelerationPanelLayout); - accelerationPanelLayout.setHorizontalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE) - ); - accelerationPanelLayout.setVerticalGroup( - accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Raw Acceleration", accelerationPanel); - - javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel); - leftPanel.setLayout(leftPanelLayout); - leftPanelLayout.setHorizontalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE) - ); - leftPanelLayout.setVerticalGroup( - leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup() - .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(irViewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation"); - - rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.LINE_AXIS)); - - fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767)); - fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setPreferredSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setRequestFocusEnabled(false); - fixedWiimotePanel.setLayout(null); - - buttonsPanel.setMaximumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setMinimumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setOpaque(false); - buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484)); - - javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(buttonsPanel); - buttonsPanel.setLayout(buttonsPanelLayout); - buttonsPanelLayout.setHorizontalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 120, Short.MAX_VALUE) - ); - buttonsPanelLayout.setVerticalGroup( - buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 484, Short.MAX_VALUE) - ); - - fixedWiimotePanel.add(buttonsPanel); - buttonsPanel.setBounds(0, 0, 120, 484); - - rightPanel.add(fixedWiimotePanel); - - controlsPanel.setMinimumSize(new java.awt.Dimension(100, 264)); - controlsPanel.setPreferredSize(new java.awt.Dimension(190, 264)); - controlsPanel.setLayout(new java.awt.GridLayout(16, 1)); - - toggleRumbleButton.setText("Activate Rumble"); - toggleRumbleButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleRumbleButtonMousePressed(evt); - } - }); - activateRumblePanel.add(toggleRumbleButton); - - controlsPanel.add(activateRumblePanel); - - toggleIRTrackingButton.setText("Activate IR Tracking"); - toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleIRTrackingButtonMousePressed(evt); - } - }); - deactivateRumblePanel.add(toggleIRTrackingButton); - - controlsPanel.add(deactivateRumblePanel); - - toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking"); - toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleMotionSensingTrackingButtonMousePressed(evt); - } - }); - activateIRtrackingPanel.add(toggleMotionSensingTrackingButton); - - controlsPanel.add(activateIRtrackingPanel); - - toggleSmoothingButton.setText("Activate Smoothing"); - toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSmoothingButtonMousePressed(evt); - } - }); - deactivateIRTrackingPanel.add(toggleSmoothingButton); - - controlsPanel.add(deactivateIRTrackingPanel); - - toggleContinuousButton.setText("Activate Continuous"); - toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleContinuousButtonMousePressed(evt); - } - }); - activateMotionSensingTrackingPanel.add(toggleContinuousButton); - - controlsPanel.add(activateMotionSensingTrackingPanel); - - led1Button.setText("Led1"); - led1Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led1ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led1Button); - - led2Button.setText("Led2"); - led2Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led2ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led2Button); - - led3Button.setText("Led3"); - led3Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led3ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led3Button); - - led4Button.setText("Led4"); - led4Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led4ButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(led4Button); - - setLedsButton.setText("Set leds"); - setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setLedsButtonMousePressed(evt); - } - }); - deactivateMotionSensingTrackingPanel.add(setLedsButton); - - controlsPanel.add(deactivateMotionSensingTrackingPanel); - - alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateSmoothingPanel.add(alphaSmoothingTextField); - - alphaSmoothingButton.setText("Set alpha smoothing"); - alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - alphaSmoothingButtonMousePressed(evt); - } - }); - activateSmoothingPanel.add(alphaSmoothingButton); - - controlsPanel.add(activateSmoothingPanel); - - orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - deactivateSmoothingPanel.add(orientationThresholdTextField); - - orientationThresholdButton.setText("Set orientation threshold"); - orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - orientationThresholdButtonMousePressed(evt); - } - }); - deactivateSmoothingPanel.add(orientationThresholdButton); - - controlsPanel.add(deactivateSmoothingPanel); - - accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20)); - activateContinuousPanel.add(accelerationThresholdTextField); - - accelerationThresholdButton.setText("Set acceleration threshold"); - accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - accelerationThresholdButtonMousePressed(evt); - } - }); - activateContinuousPanel.add(accelerationThresholdButton); - - controlsPanel.add(activateContinuousPanel); - - getStatusButton.setText("Get status"); - getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - getStatusButtonMousePressed(evt); - } - }); - deactivateContinuousPanel.add(getStatusButton); - - batteryText.setFont(new java.awt.Font("Tahoma", 0, 14)); - batteryText.setText("Battery level :"); - deactivateContinuousPanel.add(batteryText); - - batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14)); - batteryLevelText.setText(" %"); - deactivateContinuousPanel.add(batteryLevelText); - - controlsPanel.add(deactivateContinuousPanel); - - toggleSensorBarPositionButton.setText("Set sensor bar above"); - toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSensorBarPositionButtonMousePressed(evt); - } - }); - ledsPanel.add(toggleSensorBarPositionButton); - - controlsPanel.add(ledsPanel); - - toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); - toggleScreenAspectRatioButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleScreenAspectRatioButtonMousePressed(evt); - } - }); - alphaSmoothingPanel.add(toggleScreenAspectRatioButton); - - controlsPanel.add(alphaSmoothingPanel); - - xLabel.setText("X"); - orientationThresholdPanel.add(xLabel); - - xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(xResolutionTextField); - - yLabel.setText("Y"); - orientationThresholdPanel.add(yLabel); - - yResolutionTextField.setFocusTraversalPolicyProvider(true); - yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - orientationThresholdPanel.add(yResolutionTextField); - - setVirtualResolutionButton.setText("Set virtual resolution"); - setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setVirtualResolutionButtonMousePressed(evt); - } - }); - orientationThresholdPanel.add(setVirtualResolutionButton); - - controlsPanel.add(orientationThresholdPanel); - - mouseIRControlButton.setText("Start infrared mouse control"); - mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - mouseIRControlButtonMousePressed(evt); - } - }); - accelerationThresholdPanel.add(mouseIRControlButton); - - controlsPanel.add(accelerationThresholdPanel); - - expansionText.setText("No expansion connected"); - batteryPanel.add(expansionText); - - controlsPanel.add(batteryPanel); - - messageLabelText.setFont(new java.awt.Font("Tahoma", 0, 14)); - messageLabelText.setText("Message : "); - messagesPanel.add(messageLabelText); - - messageText.setFont(new java.awt.Font("Arial", 0, 14)); - messageText.setText("None"); - messagesPanel.add(messageText); - - controlsPanel.add(messagesPanel); - - rightPanel.add(controlsPanel); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE) - ); - - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - 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 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 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 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 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 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 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 getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_getStatusButtonMousePressed - wiimote.getStatus(); - statusMotionRequested = true; - statusIRRequested = true; - }//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 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 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 - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel accelerationPanel; - private javax.swing.JButton accelerationThresholdButton; - private javax.swing.JPanel accelerationThresholdPanel; - private javax.swing.JTextField accelerationThresholdTextField; - private javax.swing.JPanel activateContinuousPanel; - private javax.swing.JPanel activateIRtrackingPanel; - private javax.swing.JPanel activateMotionSensingTrackingPanel; - private javax.swing.JPanel activateRumblePanel; - private javax.swing.JPanel activateSmoothingPanel; - private javax.swing.JButton alphaSmoothingButton; - private javax.swing.JPanel alphaSmoothingPanel; - private javax.swing.JTextField alphaSmoothingTextField; - private javax.swing.JLabel batteryLevelText; - private javax.swing.JPanel batteryPanel; - private javax.swing.JLabel batteryText; - private javax.swing.JPanel buttonsPanel; - private javax.swing.JPanel controlsPanel; - private javax.swing.JPanel deactivateContinuousPanel; - private javax.swing.JPanel deactivateIRTrackingPanel; - private javax.swing.JPanel deactivateMotionSensingTrackingPanel; - private javax.swing.JPanel deactivateRumblePanel; - private javax.swing.JPanel deactivateSmoothingPanel; - private javax.swing.JLabel expansionText; - private javax.swing.JPanel fixedWiimotePanel; - private javax.swing.JPanel gForcePanel; - private javax.swing.JButton getStatusButton; - private javax.swing.JPanel irViewPanel; - private javax.swing.JTabbedPane jTabbedPane1; - private javax.swing.JButton led1Button; - private javax.swing.JButton led2Button; - private javax.swing.JButton led3Button; - private javax.swing.JButton led4Button; - private javax.swing.JPanel ledsPanel; - private javax.swing.JPanel leftPanel; - private javax.swing.JLabel messageLabelText; - private javax.swing.JLabel messageText; - private javax.swing.JPanel messagesPanel; - private javax.swing.JPanel motionSensingPanel; - private javax.swing.JButton mouseIRControlButton; - private javax.swing.JButton orientationThresholdButton; - private javax.swing.JPanel orientationThresholdPanel; - private javax.swing.JTextField orientationThresholdTextField; - private javax.swing.JPanel rightPanel; - private javax.swing.JButton setLedsButton; - private javax.swing.JButton setVirtualResolutionButton; - private javax.swing.JButton toggleContinuousButton; - private javax.swing.JButton toggleIRTrackingButton; - private javax.swing.JButton toggleMotionSensingTrackingButton; - private javax.swing.JButton toggleRumbleButton; - private javax.swing.JButton toggleScreenAspectRatioButton; - private javax.swing.JButton toggleSensorBarPositionButton; - private javax.swing.JButton toggleSmoothingButton; - private javax.swing.JLabel xLabel; - private javax.swing.JTextField xResolutionTextField; - private javax.swing.JLabel yLabel; - private javax.swing.JTextField yResolutionTextField; - // End of variables declaration//GEN-END:variables -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/AccelerationPanel.java deleted file mode 100644 index 0403255..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/AccelerationPanel.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.RawAcceleration; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch raw acceleration values from a MotionSensingEvent. - * @author guiguito - */ -public class AccelerationPanel extends javax.swing.JPanel implements 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(); - - /** Creates new form AccelerationPanel */ - public AccelerationPanel() { - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - int yLine = getHeight() - 25; - - g2.setPaint(lineColor); - g2.drawLine(0, yLine, getWidth(), yLine); - - 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; - } - - //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); - } - - /** - * 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(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getRawAcceleration()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/ButtonsEventPanel.java deleted file mode 100644 index 2a4a48f..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/ButtonsEventPanel.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.Toolkit; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what buttons are pressed. - * It displays the result of last ButtonsEvent. - * @author guiguito - */ -public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener { - - private Image mImage;//image for double buffering - private Image wiimoteImage;//image for double buffering - private ButtonsEvent buttons; - private Color pressedColor = Color.RED; - private Color heldColor = Color.ORANGE; - private Color releasedColor = Color.YELLOW; - private Shape shape; - - /** - * 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); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - 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"); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - //offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw buttons pushed - g2.drawImage(wiimoteImage, 0, 0, this); - g2.setTransform(new AffineTransform()); - - if (buttons != null) { - /* button ONE */ - if (buttons.isButtonOneJustPressed()) { - drawFunction(g2,pressedColor,53,353); - } - if (buttons.isButtonOneHeld()) { - drawFunction(g2,heldColor,53,353); - } - if (buttons.isButtonOneJustReleased()) { - drawFunction(g2, releasedColor, 53, 353); - } - - /* button TWO */ - if (buttons.isButtonTwoJustPressed()) { - drawFunction(g2,pressedColor,53,395); - } - if (buttons.isButtonTwoHeld()) { - drawFunction(g2,heldColor,53,395); - } - if (buttons.isButtonTwoJustReleased()) { - drawFunction(g2,releasedColor,53,395); - } - - /* button A */ - if (buttons.isButtonAJustPressed()) { - drawFunction(g2,pressedColor,53,150); - } - if (buttons.isButtonAHeld()) { - drawFunction(g2,heldColor,53,150); - } - if (buttons.isButtonAJustReleased()) { - drawFunction(g2,releasedColor,53,150); - } - - /* button B */ - if (buttons.isButtonBJustPressed()) { - drawFunction(g2,pressedColor,16,149); - } - if (buttons.isButtonBHeld()) { - drawFunction(g2,heldColor,16,149); - } - if (buttons.isButtonBJustReleased()) { - drawFunction(g2,releasedColor,16,149); - } - - /* button LEFT */ - if (buttons.isButtonLeftJustPressed()) { - drawFunction(g2,pressedColor,33,77); - } - if (buttons.isButtonLeftHeld()) { - drawFunction(g2,heldColor,33,77); - } - if (buttons.isButtonLeftJustReleased()) { - drawFunction(g2,releasedColor,33,77); - } - - /* button RIGHT */ - if (buttons.isButtonRightJustPressed()) { - drawFunction(g2,pressedColor,73,77); - } - if (buttons.isButtonRightHeld()) { - drawFunction(g2,heldColor,73,77); - } - if (buttons.isButtonRightJustReleased()) { - drawFunction(g2,releasedColor,73,77); - } - - /* button UP */ - if (buttons.isButtonUpJustPressed()) { - drawFunction(g2,pressedColor,54,60); - } - if (buttons.isButtonUpHeld()) { - drawFunction(g2,heldColor,54,60); - } - if (buttons.isButtonUpJustReleased()) { - drawFunction(g2,releasedColor,54,60); - } - - /* button DOWN */ - if (buttons.isButtonDownJustPressed()) { - drawFunction(g2,pressedColor,54,97); - } - if (buttons.isButtonDownHeld()) { - drawFunction(g2,heldColor,54,97); - } - if (buttons.isButtonDownJustReleased()) { - drawFunction(g2,releasedColor,54,97); - } - - /* button MINUS */ - if (buttons.isButtonMinusJustPressed()) { - drawFunction(g2,pressedColor,20,230); - } - if (buttons.isButtonMinusHeld()) { - drawFunction(g2,heldColor,20,230); - } - if (buttons.isButtonMinusJustReleased()) { - drawFunction(g2,releasedColor,20,230); - } - - /* button PLUS */ - if (buttons.isButtonPlusJustPressed()) { - drawFunction(g2,pressedColor,86,230); - } - if (buttons.isButtonPlusHeld()) { - drawFunction(g2,heldColor,86,230); - } - if (buttons.isButtonPlusJustReleased()) { - drawFunction(g2,releasedColor,86,230); - } - - /* button HOME */ - if (buttons.isButtonHomeJustPressed()) { - drawFunction(g2,pressedColor,53,230); - } - if (buttons.isButtonHomeHeld()) { - drawFunction(g2,heldColor,53,230); - } - if (buttons.isButtonHomeJustReleased()) { - drawFunction(g2,releasedColor,53,230); - } - - buttons = null; - } - - - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * Function used to factorize code. - * @param g2 where to draw a shape. - * @param col color to use. - * @param x x coordinates. - * @param y y coordinates. - */ - private void drawFunction(Graphics2D g2, Color col, int x, int y) { - g2.setPaint(col); - g2.translate(x, y); - g2.draw(shape); - g2.fill(shape); - g2.setTransform(new AffineTransform()); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); - buttons = arg0; - repaint(); - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - 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() { - - 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/GForcePanel.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/GForcePanel.java deleted file mode 100644 index 9802688..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/GForcePanel.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.GForce; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch gravity force values from a MotionSensingEvent. - * @author guiguito - */ -public class GForcePanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor of the AccelerationPanel. - */ - public GForcePanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * @param bgColor background color. - * @param xxColor color of the acceleration on X axis. - * @param yyColor color of the acceleration on Y axis. - * @param zzColor color of the acceleration on Z axis. - * @param lColor line color. - */ - public GForcePanel(Color bgColor, Color xxColor, Color yyColor, Color zzColor, Color lColor) { - backgroundColor = bgColor; - xColor = xxColor; - yColor = yyColor; - zColor = zzColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - GForce[] valuesArray = values.toArray(new GForce[0]); - double unit = yMiddleFloat / 5.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - GForce gforce = valuesArray[i]; - //draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * gforce.getX()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - //draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * gforce.getY()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - //draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * gforce.getZ()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } - - //draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("5", 2, 10); - g2.drawString("-5", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getGforce()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/IRPanel.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/IRPanel.java deleted file mode 100644 index 4526206..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/IRPanel.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to see what the IR camera of the wiimote sees. - * @author guiguito - */ -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; - - /** - * Default constructor for IR Panel. - * Background color : black. - * IR sources color : yellow. - * Border color of IR sources : blue. - * Shape of the IR sources : circle with a diameter of 10. - */ - public IRPanel() { - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); - initArrays(); - initComponents(); - } - - /** - * Constructor used to parameterize the IR panel. - * @param bgColor color. - * @param ptColor IR sources color. - * @param bdColor border color of IR sources. - * @param sh Shape of the IR sources. - */ - public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { - backgroundColor = bgColor; - color = ptColor; - borderColor = bdColor; - shape = sh; - initArrays(); - initComponents(); - } - - private void initArrays(){ - xCoordinates = new int[MAX_NB_POINTS]; - yCoordinates = new int[MAX_NB_POINTS]; - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw points - int i = 0; - while (i < nbPoints) { - double x = xCoordinates[i]; - double y = yCoordinates[i]; - - long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); - long yy = getHeight() - Math.round((double) getHeight() * y / 768.0); - g2.translate(xx, yy); - - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(color); - g2.fill(shape); - - g2.setTransform(new AffineTransform()); - i++; - } - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - repaint(); - } - - public void onIrEvent(IREvent arg0) { - //transfer points - wiiusej.values.IRSource[] points = arg0.getIRPoints(); - nbPoints = points.length; - for (int i = 0; i < points.length; i++) { - xCoordinates[i] = (int) points[i].getRx(); - yCoordinates[i] = (int) points[i].getRy(); - } - for (int i = points.length; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - - //redraw panel - repaint(); - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - //nothing - } - - public void 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(); - } - - /** 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 -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/OrientationPanel.java deleted file mode 100644 index b50a2ce..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/utils/OrientationPanel.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; -import wiiusej.values.Orientation; -import wiiusej.wiiuseapievents.ButtonsEvent; -import wiiusej.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiuseapievents.IREvent; -import wiiusej.wiiuseapievents.MotionSensingEvent; -import wiiusej.wiiuseapievents.StatusEvent; -import wiiusej.wiiuseapievents.WiimoteListener; - -/** - * This panel is used to watch orientation values from a MotionSensingEvent. - * @author guiguito - */ -public class OrientationPanel extends javax.swing.JPanel implements 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(); - - /** - * Default constructor. - * Background color : White. - * Roll color : Red. - * Pitch color : Green. - * Yaw color : Blue. - */ - public OrientationPanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the OrientationPanel. - * @param bgColor background color. - * @param rColor roll color. - * @param pColor pitch color. - * @param yColor yaw color. - * @param lColor line color. - */ - public OrientationPanel(Color bgColor, Color rColor, Color pColor, Color yColor, Color lColor) { - backgroundColor = bgColor; - rollColor = rColor; - pitchColor = pColor; - yawColor = yColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - //draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - Orientation[] valuesArray = values.toArray(new Orientation[0]); - double unit = yMiddleFloat / 180.0; - int previousRoll = 0; - int previousPitch = 0; - int previousYaw = 0; - //draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - Orientation orientation = valuesArray[i]; - //draw roll - g2.setPaint(rollColor); - int yDelta = (int) Math.round(unit * orientation.getRoll()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousRoll, i, y); - g2.setTransform(new AffineTransform()); - previousRoll = y; - //draw pitch - g2.setPaint(pitchColor); - yDelta = (int) Math.round(unit * orientation.getPitch()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousPitch, i, y); - g2.setTransform(new AffineTransform()); - previousPitch = y; - //draw yaw - g2.setPaint(yawColor); - yDelta = (int) Math.round(unit * orientation.getYaw()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i-1, previousYaw, i, y); - g2.setTransform(new AffineTransform()); - previousYaw = y; - } - - //draw legend - g2.setPaint(rollColor); - g2.drawLine(5, getHeight()-10, 25, getHeight()-10); - g2.setPaint(pitchColor); - g2.drawLine(60, getHeight()-10, 80, getHeight()-10); - g2.setPaint(yawColor); - g2.drawLine(120, getHeight()-10, 140, getHeight()-10); - - g2.setPaint(lineColor); - g2.drawString("Roll", 30, getHeight()-5); - g2.drawString("Pitch", 85, getHeight()-5); - g2.drawString("Yaw", 145, getHeight()-5); - g2.drawString("0", 2, yMiddle-5); - g2.drawString("180", 2, 10); - g2.drawString("-180", 2, getHeight()-15); - //put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case it initializes it - * with the dimensions of the panel. mImage is for double buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(ButtonsEvent arg0) { - //nothing - } - - public void onIrEvent(IREvent arg0) { - //nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - if (values.size() >= getWidth()) { - //if there are as many values as pixels in the width - //clear points - values.clear(); - } - values.add(arg0.getOrientation()); - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - //nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - //Clear points. - 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() { - - 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/GForce.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/GForce.java deleted file mode 100644 index 9732121..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/GForce.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents gravity force on each axis. - * @author guiguito - */ -public class GForce { - - private float x; - private float y; - private float z; - - /** - * 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; - } - - /** - * @return the x - */ - public float getX() { - return x; - } - - /** - * @return the y - */ - public float getY() { - return y; - } - - /** - * @return the z - */ - public float getZ() { - return z; - } - - @Override - public String toString() { - return "Gravity force : ("+x+", "+y+","+z+")"; - } -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/IRSource.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/IRSource.java deleted file mode 100644 index 7caef55..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/IRSource.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class used for IR sources. - * @author guiguito - */ -public class IRSource{ - - 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; - } - - - /** - * 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 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 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+")"; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/Orientation.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/Orientation.java deleted file mode 100644 index 4c4f741..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/Orientation.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class that represents the orientation of the wiimote. - * @author guiguito - */ -public class Orientation { - - private float roll; - private float pitch; - private float yaw; - - /** - * Default constructor. - */ - public Orientation(){ - roll = 0; - pitch = 0; - yaw = 0; - } - - /** - * Contructor with raw, pitch , yaw. - * @param r raw - * @param p pitch - * @param y yaw - */ - public Orientation(float r, float p, float y){ - roll = r; - pitch = p; - yaw = y; - } - - /** - * @return the roll - */ - public float getRoll() { - return roll; - } - - /** - * @return the pitch - */ - public float getPitch() { - return pitch; - } - - /** - * @return the yaw - */ - public float getYaw() { - return yaw; - } - - @Override - public String toString() { - return "Orientation : (roll: "+roll+", pitch: "+pitch+", yaw: "+yaw+")"; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/RawAcceleration.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/RawAcceleration.java deleted file mode 100644 index 903a51c..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/values/RawAcceleration.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents raw acceleration on each axis. - * @author guiguito - */ -public class RawAcceleration { - - private short x; - private short y; - private short z; - - /** - * 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; - } - - /** - * @return the x - */ - public short getX() { - return x; - } - /** - * @return the y - */ - public short getY() { - return y; - } - - /** - * @return the z - */ - public short getZ() { - return z; - } - - @Override - public String toString() { - return "Raw acceleration : ("+x+", "+y+","+z+")"; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/ButtonsEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/ButtonsEvent.java deleted file mode 100644 index ce78551..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/ButtonsEvent.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class which represents a buttons event. - * @author guiguito - */ -public class ButtonsEvent extends WiimoteEvent{ - - /* 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 */ - 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); - } - - /** - * 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 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; - } - - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ - - private boolean buttonTest(short buttonBitsDefinition, short buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } - - private boolean isButtonJustPressed(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } - - private boolean isButtonJustReleased(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } - - private boolean isButtonHeld(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } - - private boolean isButtonPressed(short buttonBitsDefinition) { - return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition); - } - /* Button ONE */ - - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOnePressed() { - return isButtonPressed(WIIMOTE_BUTTON_ONE); - } - - /* Button TWO */ - - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoPressed() { - return isButtonPressed(WIIMOTE_BUTTON_TWO); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAPressed() { - return isButtonPressed(WIIMOTE_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBPressed() { - return isButtonPressed(WIIMOTE_BUTTON_B); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftPressed() { - return isButtonPressed(WIIMOTE_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightPressed() { - return isButtonPressed(WIIMOTE_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpPressed() { - return isButtonPressed(WIIMOTE_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownPressed() { - return isButtonPressed(WIIMOTE_BUTTON_DOWN); - } - - /* Button - */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_MINUS); - } - - /* Button + */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_PLUS); - } - - /* Button HOME */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomePressed() { - return isButtonPressed(WIIMOTE_BUTTON_HOME); - } - - @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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/DisconnectionEvent.java deleted file mode 100644 index 341b626..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/DisconnectionEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class representing a disconnection event. - * @author guiguito - */ -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); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; - - return out; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/EventsGatherer.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/EventsGatherer.java deleted file mode 100644 index 5c83d78..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/EventsGatherer.java +++ /dev/null @@ -1,241 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class is used to gather events during a call to the Wiiuse API. - * - * @author guiguito - */ -public class EventsGatherer { - - private WiiUseApiEvent[] events; - private int index = 0; - private GenericEvent 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]; - } - - /** - * 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 GenericEvent(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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, - yOffset, sensorBarPostion, screenAsPectRatio); - - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - if (genericEvent != null) { - genericEvent.setMotionSensingEvent(orientationThreshold, - accelerationThreshold, smoothingState, alphaSmooth, r, p, - ya, x, y, z, xx, yy, zz); - } - } - - /** - * 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 DisconnectionEvent to the gatherer. - * - * @param id - * id of the wiimote - */ - public void addDisconnectionEvent(int id) { - DisconnectionEvent evt = new DisconnectionEvent(id); - addEvent(evt); - } - - /** - * Return an array containing the events. - * - * @return events received - */ - public WiiUseApiEvent[] getEvents() { - return java.util.Arrays.copyOfRange(events, 0, index); - } - - /** - * 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/GenericEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/GenericEvent.java deleted file mode 100644 index e8ea39b..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/GenericEvent.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class that is a bean to be filled by the wiiuse API. - * - * @author guiguito - */ -public class GenericEvent extends WiiUseApiEvent { - - ButtonsEvent buttonsEvent = null; - IREvent infraredEvent = null; - MotionSensingEvent motionSensingEvent = null; - - /** - * Construct the Wiimote setting up the id. - * - * @param id - * the Wiimote id - */ - public GenericEvent(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 GenericEvent(int id, short buttonsJustPressed, - short buttonsJustReleased, short buttonsHeld) { - super(id, WiiUseApiEvent.GENERIC_EVENT); - buttonsEvent = new ButtonsEvent(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 a motion sensing Event. - * - * @return TRUE if there is a motion sensing event. - */ - public boolean isThereMotionSensingEvent() { - return motionSensingEvent != null; - } - - /** - * Get buttons event. - * - * @return the buttons event. - */ - public ButtonsEvent getButtonsEvent() { - return buttonsEvent; - } - - /** - * Get IR event. - * - * @return the IR event if there is one or null. - */ - public IREvent getIREvent() { - return infraredEvent; - } - - /** - * Get motion sensing event. - * - * @return the motion sensing event if there is one or null. - */ - public MotionSensingEvent getMotionSensingEvent() { - return motionSensingEvent; - } - - /** - * 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. - */ - public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - if (infraredEvent == null) { - infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, - yVRes, xOffset, yOffset, sensorBarPostion, - screenAsPectRatio); - } - } - - /** - * 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 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 x, float y, - float z, short xx, short yy, short zz) { - motionSensingEvent = new MotionSensingEvent(getWiimoteId(), - orientationThreshold, accelerationThreshold, smoothingState, - alphaSmooth, r, p, ya, x, y, z, xx, yy, zz); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GENERIC EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - - out += buttonsEvent; - - 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"; - } - - return out; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/IREvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/IREvent.java deleted file mode 100644 index 6007e97..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/IREvent.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.IRSource; - -/** - * Class which represents an IR event. - * - * @author guiguito - */ -public class IREvent extends WiimoteEvent { - - /* IR Tracking */ - private IRSource[] IRPoints; - private short indexPoints = 0; - private int x; - private int y; - private int 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; - - 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 - - /** - * 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. - */ - public IREvent(int id, int x, int y, int z, int ax, int ay, int xVRes, - int yVRes, int xOffset, int yOffset, short sensorBarPostion, - short screenAsPectRatio) { - 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; - IRPoints = new IRSource[NB_POINTS]; - } - - /** - * Get list of IR points. - * - * @return the list of 2D points - */ - public IRSource[] getIRPoints() { - return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints); - } - - /** - * 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 Y coordinate. - * - * @return the y - */ - public int getY() { - return y; - } - - /** - * Return calculated distance. - * - * @return the z - */ - public int getZ() { - return z; - } - - /** - * 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 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 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 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 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 aspect ratio of the screen. - * - * @return the screenAsPectRatio - */ - public short getScreenAsPectRatio() { - return screenAsPectRatio; - } - - @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 distance : " + z + "\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"; - 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/MotionSensingEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/MotionSensingEvent.java deleted file mode 100644 index 6ec7712..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/MotionSensingEvent.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -import wiiusej.values.GForce; -import wiiusej.values.Orientation; -import wiiusej.values.RawAcceleration; - -/** - * Class which represents a motion sensing event. - * - * @author guiguito - */ -public class MotionSensingEvent extends WiimoteEvent { - - /* 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; - - /** - * 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 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 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, x, y, z, xx, yy, zz); - } - - /** - * Set orientation, gravity force and raw acceleration. - * - * @param r - * roll - * @param p - * pitch - * @param ya - * yaw - * @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 x, - float y, float z, short xx, short yy, short zz) { - this.orientation = new Orientation(r, p, ya); - this.gforce = new GForce(x, y, z); - this.acceleration = new RawAcceleration(xx, yy, zz); - } - - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * 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 orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } - - /** - * Get acceleration threshold. - * - * @return the accelerationThreshold - */ - public int getAccelerationThreshold() { - return accelerationThreshold; - } - - /** - * 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; - } - - @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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/StatusEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/StatusEvent.java deleted file mode 100644 index 7a365fc..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/StatusEvent.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Class used to represent a status event. This class is used to know what are - * the settings of the wiimote. - * - * @author guiguito - */ -public class StatusEvent extends WiiUseApiEvent { - - private static short WIIMOTE_LED_1 = 1; - private static short WIIMOTE_LED_2 = 2; - private static short WIIMOTE_LED_3 = 4; - private static short WIIMOTE_LED_4 = 8; - - /* 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; - - /* Status variables */ - private boolean connected = false; - - private float batteryLevel = -1; - - private short leds = 0; - - private boolean isSpeakerEnabled = false; - - private int attachment = 0; - - private boolean isRumbleActive = false; - - private boolean isContinuousActive = false; - - private boolean isIrActive = 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); - } - - /** - * 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; - } - - /** - * 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 led1 status. - * - * @return true if the led is set. - */ - public boolean isLed1Set() { - if ((leds & WIIMOTE_LED_1) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led2 status. - * - * @return true if the led is set. - */ - public boolean isLed2Set() { - if ((leds & WIIMOTE_LED_2) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led3 status. - * - * @return true if the led is set. - */ - public boolean isLed3Set() { - if ((leds & WIIMOTE_LED_3) > 0) { - return true; - } else { - return false; - } - } - - /** - * Get led4 status. - * - * @return true if the led is set. - */ - public boolean isLed4Set() { - if ((leds & WIIMOTE_LED_4) > 0) { - return true; - } else { - return false; - } - } - - /** - * 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 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 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; - } - - @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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java deleted file mode 100644 index 880c632..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This class describes the structure of an event from the WiiUse API event. - * - * @author guiguito - */ -public abstract class WiiUseApiEvent extends WiimoteEvent{ - - public static int GENERIC_EVENT = 1; - public static int STATUS_EVENT = 2; - public static int DISCONNECTION_EVENT = 3; - public static int WIIUSE_NUNCHUK_INSERTED = 4; - public static int WIIUSE_NUNCHUK_REMOVED = 5; - public static int WIIUSE_CLASSIC_CTRL_INSERTED = 6; - public static int WIIUSE_CLASSIC_CTRL_REMOVED = 7; - public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 8; - public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 9; - - /* 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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiListener.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiListener.java deleted file mode 100644 index 3f6bb22..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiiUseApiListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - - - -/** - * This is the interface to implement to listen to events from the wiiuse API. - * - * @author guiguito - */ -public interface WiiUseApiListener extends java.util.EventListener { - - /** - * Method called when a WiiUseApiEvent occurs. - * A WiiUseApiEvent can be : - * - GenericEvent (Storing ButtonsEvent and - * eventually IREvent and MotionSensingEvent) - * - StatusEvent - * - DisconnectionEvent - * @param e - */ - void onWiiUseApiEvent(WiiUseApiEvent e); - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteEvent.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteEvent.java deleted file mode 100644 index 1504a37..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * Abstract mother class representing an event with a wiimote id. - * - * @author guiguito - */ -public abstract class WiimoteEvent { - - /* ID */ - private int wiimoteId = -1; - - /** - * Construct the WiiUseApiEvent setting up the id. - * - * @param id - * the Wiimote id - */ - public WiimoteEvent(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/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteListener.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteListener.java deleted file mode 100644 index 3ea3c05..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapievents/WiimoteListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapievents; - -/** - * This is the interface to implement to listen to events from wiimotes. - * The differents methods are called in this order : - * onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent. - * - * @author guiguito - */ -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(ButtonsEvent 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 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); - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/FloatValueRequest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/FloatValueRequest.java deleted file mode 100644 index a003239..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/FloatValueRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with a float value to pass to wiiuse API. - * - * @author guiguito - */ -public class FloatValueRequest extends WiiUseApiRequest { - - private float floatValue; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public FloatValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * threshold in degrees - */ - public FloatValueRequest(int id, int type, float th) { - super(id, type); - floatValue = th; - } - - /** - * Get the float value. - * @return the float value - */ - public float getFloatValue() { - return floatValue; - } - - /** - * Set the float value. - * @param val the value to set - */ - public void setFloatValue(float val) { - this.floatValue = val; - } - - - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/IntValueRequest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/IntValueRequest.java deleted file mode 100644 index 801093d..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/IntValueRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request with an int value to pass to wiiuse API. - * - * @author guiguito - */ -public class IntValueRequest extends WiiUseApiRequest { - - private int intValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id - * the id of the wiimote concerned. - */ - public IntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the int value. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * the int value. - */ - public IntValueRequest(int id, int type, int th) { - super(id, type); - intValue = th; - } - - /** - * Get the int value. - * @return the int value - */ - public int getIntValue() { - return intValue; - } - - /** - * Set the int value. - * @param val the value to set - */ - public void setIntValue(int val) { - this.intValue = val; - } - - - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/LedsRequest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/LedsRequest.java deleted file mode 100644 index 1a21024..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/LedsRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request to set leds of the wiimote with WiiUse API. - * - * @author guiguito - */ -public class LedsRequest extends wiiusej.wiiuseapirequest.WiiUseApiRequest { - - private boolean led1, led2, led3, led4; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - */ - public LedsRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - * @param l1 - * led1 status. True=ON, False=OFF - * @param l2 - * led2 status. True=ON, False=OFF - * @param l3 - * led3 status. True=ON, False=OFF - * @param l4 - * led4 status. True=ON, False=OFF - */ - public LedsRequest(int id, int type, boolean l1, boolean l2, boolean l3, - boolean l4) { - super(id, type); - led1 = l1; - led2 = l2; - led3 = l3; - led4 = l4; - } - - /** - * @return the led1 - */ - public boolean isLed1() { - return led1; - } - - /** - * @param led1 - * the led1 to set - */ - public void setLed1(boolean led1) { - this.led1 = led1; - } - - /** - * @return the led2 - */ - public boolean isLed2() { - return led2; - } - - /** - * @param led2 - * the led2 to set - */ - public void setLed2(boolean led2) { - this.led2 = led2; - } - - /** - * @return the led3 - */ - public boolean isLed3() { - return led3; - } - - /** - * @param led3 - * the led3 to set - */ - public void setLed3(boolean led3) { - this.led3 = led3; - } - - /** - * @return the led4 - */ - public boolean isLed4() { - return led4; - } - - /** - * @param led4 - * the led4 to set - */ - public void setLed4(boolean led4) { - this.led4 = led4; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java deleted file mode 100644 index 98e907e..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - - -/** - * Represents a request with two int values to pass to wiiuse API. - * - * @author guiguito - */ -public class TwoIntValueRequest extends IntValueRequest { - - private int secondIntValue; - - /** - * Constructor setting the id of the wiimote - * concerned and the type of the request. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - */ - public TwoIntValueRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote - * concerned, the type of the request - * and the two int values. - * - * @param id the id of the wiimote concerned. - * @param type type of the request - * @param x first int value. - * @param y second int value. - */ - public TwoIntValueRequest(int id, int type, int x, int y) { - super(id, type, x); - secondIntValue = y; - } - - /** - * Get the second int value. - * @return the secondIntValue - */ - public int getSecondIntValue() { - return secondIntValue; - } - - /** - * Set the second int value. - * @param secondIntValue the secondIntValue to set. - */ - public void setSecondIntValue(int secondIntValue) { - this.secondIntValue = secondIntValue; - } - - - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java b/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java deleted file mode 100644 index 1f4525b..0000000 --- a/WiiUseJ_0.11ThreadReqeuests/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiuseapirequest; - -/** - * Represents a request we could do to the WiiUse API. - * - * @author guiguito - */ -public class WiiUseApiRequest { - - public static int WIIUSE_STATUS_REQUEST = 1; - public static int WIIUSE_ACTIVATE_SMOOTHING_REQUEST = 2; - public static int WIIUSE_DEACTIVATE_SMOOTHING_REQUEST = -2; - public static int WIIUSE_ACTIVATE_IR_TRACKING_REQUEST = 3; - public static int WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST = -3; - public static int WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST = 4; - public static int WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST = -4; - public static int WIIUSE_CLOSE_CONNECTION_REQUEST = 5; - public static int WIIUSE_ACTIVATE_CONTINUOUS_REQUEST = 6; - public static int WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST = -6; - public static int WIIUSE_ACTIVATE_RUMBLE_REQUEST = 7; - public static int WIIUSE_DEACTIVATE_RUMBLE_REQUEST = -7; - public static int WIIUSE_LEDS_REQUEST = 8; - public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9; - public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10; - public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11; - public static int WIIUSE_RESYNC = 12; - public static int WIIUSE_ASPECT_RATIO_4_3 = 13; - public static int WIIUSE_ASPECT_RATIO_16_9 = 14; - public static int WIIUSE_SENSOR_BAR_ABOVE = 15; - public static int WIIUSE_SENSOR_BAR_BELOW = 16; - public static int WIIUSE_SET_VIRTUAL_RESOLUTION = 17; - - private int wiimoteId = 0; - private int requestType = 0; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public WiiUseApiRequest(int id) { - wiimoteId = id; - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * - */ - public WiiUseApiRequest(int id, int type) { - wiimoteId = id; - requestType = type; - } - - /** - * Get id of the wiimote concerned by this request. - * - * @return id of the wiimote concerned - */ - public int getId() { - return wiimoteId; - } - - /** - * Set id of the wiimote concerned by this request. - * - * @param id - * id fh the wiimote concernet - */ - public void setId(int id) { - wiimoteId = id; - } - - /** - * Get the request type. - * - * @return the requestType - */ - public int getRequestType() { - return requestType; - } - - /** - * Set the request type. - * - * @param requestType - * the requestType to set - */ - public void setRequestType(int requestType) { - this.requestType = requestType; - } - -} diff --git a/WiiUseJ_0.11ThreadReqeuests/wiiuse.dll b/WiiUseJ_0.11ThreadReqeuests/wiiuse.dll deleted file mode 100644 index 6855619..0000000 Binary files a/WiiUseJ_0.11ThreadReqeuests/wiiuse.dll and /dev/null differ diff --git a/WiiUseJ_0.12/.classpath b/WiiUseJ_0.12/.classpath deleted file mode 100644 index d171cd4..0000000 --- a/WiiUseJ_0.12/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/WiiUseJ_0.12/.project b/WiiUseJ_0.12/.project deleted file mode 100644 index 9485f4a..0000000 --- a/WiiUseJ_0.12/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - WiiUseJava - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/WiiUseJ_0.12/.settings/org.eclipse.jdt.ui.prefs b/WiiUseJ_0.12/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 81f7b8f..0000000 --- a/WiiUseJ_0.12/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Thu May 08 01:25:43 CEST 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/WiiUseJ_0.12/README.TXT b/WiiUseJ_0.12/README.TXT deleted file mode 100644 index ba8e176..0000000 --- a/WiiUseJ_0.12/README.TXT +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ - - -WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI. - -WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes. - -Some of the great aspects of this API are : - - * The compatibility which is as large as Wiiuse's API compatibility - - * Cross-platform : Windows and linux (like Wiiuse) - - * Easy to use - - -WiiuseJ is made by Guilhem Duché : guiguito1@hotmail.com. -You can contact me if you need more information. - -Go to : http://wiiusej.googlecode.com/ for further documentations. - - - -CHANGELOG : - -wiiusej 0.12 : -- added nunchuk support. -- all new stuffs from wiiuse 0.12. -- added timeout method. -- added IR sensitivity. -- updated to be able to reconnect wiimotes. -- new architecture behind the scene. -- cleaning of the project. - -wiiusej 0.11 : -- updated with new stuffs from wiiuse 0.11. -- Linux version. -- selectionnable rumble on wiimotes connection. - -wiiusej 0.1 : -- first version on wiiuse 0.1. \ No newline at end of file diff --git a/WiiUseJ_0.12/WiiUseJ.dll b/WiiUseJ_0.12/WiiUseJ.dll deleted file mode 100644 index aeebf07..0000000 Binary files a/WiiUseJ_0.12/WiiUseJ.dll and /dev/null differ diff --git a/WiiUseJ_0.12/img/wiimote.png b/WiiUseJ_0.12/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.12/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.12/libWiiuseJ.so b/WiiUseJ_0.12/libWiiuseJ.so deleted file mode 100644 index 0caea08..0000000 Binary files a/WiiUseJ_0.12/libWiiuseJ.so and /dev/null differ diff --git a/WiiUseJ_0.12/libwiiuse.so b/WiiUseJ_0.12/libwiiuse.so deleted file mode 100644 index 481e0e2..0000000 Binary files a/WiiUseJ_0.12/libwiiuse.so and /dev/null differ diff --git a/WiiUseJ_0.12/src/img/wiimote.png b/WiiUseJ_0.12/src/img/wiimote.png deleted file mode 100644 index 3f26f52..0000000 Binary files a/WiiUseJ_0.12/src/img/wiimote.png and /dev/null differ diff --git a/WiiUseJ_0.12/src/wiiusej/WiiUseApi.java b/WiiUseJ_0.12/src/wiiusej/WiiUseApi.java deleted file mode 100644 index 428f522..0000000 --- a/WiiUseJ_0.12/src/wiiusej/WiiUseApi.java +++ /dev/null @@ -1,351 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import wiiusej.wiiusejevents.utils.EventsGatherer; - -/** - * Singleton used to manipulate WiiUse Api. - * - * @author guiguito - */ -public class WiiUseApi { - - static { - System.loadLibrary("WiiuseJ"); - } - - private static WiiUseApi instance = new WiiUseApi(); - - /** - * 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); - - /** - * 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); - - /** - * 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); - - /** - * 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); - - /** - * 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); - - /** - * 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); - - /** - * 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 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 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); - - /** - * 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 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); - - /** - * 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 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); - - /** - * 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); - - /** - * 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 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); - - /** - * 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); - -} diff --git a/WiiUseJ_0.12/src/wiiusej/WiiUseApiManager.java b/WiiUseJ_0.12/src/wiiusej/WiiUseApiManager.java deleted file mode 100644 index 9378660..0000000 --- a/WiiUseJ_0.12/src/wiiusej/WiiUseApiManager.java +++ /dev/null @@ -1,662 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import java.util.concurrent.Semaphore; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiusejevents.utils.EventsGatherer; -import wiiusej.wiiusejevents.utils.WiiUseApiListener; -import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; - -/** - * Class that manages the use of Wiiuse API. - * - * @author guiguito - */ -public class WiiUseApiManager extends Thread { - - private static WiiUseApiManager instance = new WiiUseApiManager(); - - private final EventListenerList listeners = new EventListenerList(); - - private Semaphore semaphore = new Semaphore(0); - - private Wiimote[] wiimotes; - - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - - private int connected = -1; - - private AtomicBoolean running = new AtomicBoolean(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; - - private 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.* - * @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(); - - 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) {// no wiimote connected - // return empty array - return new Wiimote[0]; - } - - if (!manager.isAlive())// start wiiuseJ polling - manager.start(); - - manager.semaphore.release(1); - - 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; - } - } - - /** - * 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].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; - } - - /** - * Stop thread and shutdown wiiuse Api. - */ - public static void shutdown() { - WiiUseApiManager manager = getInstance(); - if (manager.connected > 0) { - for (Wiimote wim : manager.wiimotes) { - if (wim != null) - wim.disconnect(); - } - } - manager.running.set(false); - 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(); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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 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); - } - - /** - * 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 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 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); - } - - /** - * 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 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 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); - } - - @Override - public void run() { - - while (!leave) { - try { - semaphore.acquire(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - if (connected > 0) { - running.set(true); - - EventsGatherer gather = new EventsGatherer(connected); - - // Start polling and tell the observers when there are Wiimote - // events - while (running.get() && connected > 0) { - - /* 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 - } - - /** - * 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); - } - - /** - * 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); - } - } - - /** - * Called by the garbage collector at the end. - */ - protected void finalize() throws Throwable { - shutdown(); - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/Wiimote.java b/WiiUseJ_0.12/src/wiiusej/Wiimote.java deleted file mode 100644 index 98a5233..0000000 --- a/WiiUseJ_0.12/src/wiiusej/Wiimote.java +++ /dev/null @@ -1,435 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej; - -import javax.swing.event.EventListenerList; - -import wiiusej.wiiusejevents.utils.WiiUseApiListener; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; -import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent; - -/** - * Class that represents a wiimote. You can register as an observer of this - * wiimote to listen events from it. You manage it. - * - * @author guiguito - */ -public class Wiimote implements WiiUseApiListener { - - private int id = -1;// wiimote id - - private EventListenerList listeners = new EventListenerList(); - - 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; - } - - /** - * 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); - } - - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } - - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } - - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } - - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } - - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } - - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } - - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } - - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } - - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(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 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 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 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 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 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); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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); - } - /* - * 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); - } - - /** - * 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); - } - - /** - * 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 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 NunchukRemoved Event occured. - * - * @param evt - * NunchukRemoved Event occured - */ - private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.onNunchukRemovedEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : " + id; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/test/CloseGuiTestCleanly.java b/WiiUseJ_0.12/src/wiiusej/test/CloseGuiTestCleanly.java deleted file mode 100644 index 584f2d9..0000000 --- a/WiiUseJ_0.12/src/wiiusej/test/CloseGuiTestCleanly.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import wiiusej.WiiUseApiManager; - -/** - * This class is used to close wiiusej cleanly. - * - * @author guiguito - */ -public class CloseGuiTestCleanly implements WindowListener { - - public void windowOpened(WindowEvent e) { - // nothing - } - - public void windowClosing(WindowEvent e) { - WiiUseApiManager.definitiveShutdown(); - } - - public void windowClosed(WindowEvent e) { - // nothing - } - - public void windowIconified(WindowEvent e) { - // nothing - } - - public void windowDeiconified(WindowEvent e) { - // nothing - } - - public void windowActivated(WindowEvent e) { - // nothing - } - - public void windowDeactivated(WindowEvent e) { - // nothing - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/test/Main.java b/WiiUseJ_0.12/src/wiiusej/test/Main.java deleted file mode 100644 index 67ef279..0000000 --- a/WiiUseJ_0.12/src/wiiusej/test/Main.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; - -/** - * Main Class to launch WiiuseJ GUI Test. - * - * @author guiguito - */ -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); - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/test/NunchukGuiTest.java b/WiiUseJ_0.12/src/wiiusej/test/NunchukGuiTest.java deleted file mode 100644 index 7054de8..0000000 --- a/WiiUseJ_0.12/src/wiiusej/test/NunchukGuiTest.java +++ /dev/null @@ -1,377 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import wiiusej.Wiimote; -import wiiusej.utils.AccelerationExpansionEventPanel; -import wiiusej.utils.AccelerationPanel; -import wiiusej.utils.GForceExpansionEventPanel; -import wiiusej.utils.GForcePanel; -import wiiusej.utils.NunchukJoystickEventPanel; -import wiiusej.utils.OrientationExpansionEventPanel; -import wiiusej.utils.OrientationPanel; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukButtonsEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This frame is used to display events from a nunchuk. - * - * @author guiguito - */ -public class NunchukGuiTest extends javax.swing.JFrame implements - WiimoteListener { - - private Wiimote wiimote; - private boolean isThresholdsRequested = true; - - /** 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); - } - - 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; - } - - /** - * 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 = 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)); - - 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)); - - 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"); - - motionSensingEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200)); - - 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) - ); - - 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) - ); - - 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) - ); - - 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) - ); - - topPanels.add(motionSensingEventsPanel); - - 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)); - - 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); - - 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); - - 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); - - setNunchukValuesPanel.add(nunchukOrientationPanel); - - 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); - - setNunchukValuesPanel.add(nunchukAccelerationPanel); - - 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))) - ); - - setNunchukValuesPanel.add(messagePanel); - - getContentPane().add(setNunchukValuesPanel); - - 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 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 onIrEvent(IREvent 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(); - if (buttons.isButtonCJustPressed()) { - cButton.setEnabled(false); - } - if (buttons.isButtonCJustReleased()) { - cButton.setEnabled(true); - } - if (buttons.isButtonZJustPressed()) { - zButton.setEnabled(false); - } - if (buttons.isButtonZJustReleased()) { - zButton.setEnabled(true); - } - 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 onDisconnectionEvent(DisconnectionEvent arg0) { - // nothing - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent 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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/test/Tests.java b/WiiUseJ_0.12/src/wiiusej/test/Tests.java deleted file mode 100644 index 6a3cdb7..0000000 --- a/WiiUseJ_0.12/src/wiiusej/test/Tests.java +++ /dev/null @@ -1,367 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; - -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.values.IRSource; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This class used to test WiiuseJ in text mode. - * - * @author guiguito - */ -public class Tests implements WiimoteListener { - - 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 Wiimote wiimote; - - int dump = DISPLAY_EACH_VALUE; - - 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"); - } - - /* 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 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 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 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 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"); - } - - /* 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 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(); - } - - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - - } 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(); - } - - /* 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); - } - - /* 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(); - } - } - - } - - 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); - } - } - - public void onMotionSensingEvent(MotionSensingEvent e) { - /* display motion sensing */ - System.out.println(e); - } - - public void onExpansionEvent(ExpansionEvent e) { - System.out.println(e); - } - - public void onStatusEvent(StatusEvent e) { - // Display status variables - System.out.println(e); - } - - public void onDisconnectionEvent(DisconnectionEvent e) { - System.out.println(" wiimote " + e.getWiimoteId() - + "has been disconnected !!"); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - System.out.println(e); - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - System.out.println(e); - } - - /** - * @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); - - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ_0.12/src/wiiusej/test/WiiuseJGuiTest.java deleted file mode 100644 index 2a8f229..0000000 --- a/WiiUseJ_0.12/src/wiiusej/test/WiiuseJGuiTest.java +++ /dev/null @@ -1,1329 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.test; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.JFrame; -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.utils.AccelerationPanel; -import wiiusej.utils.AccelerationWiimoteEventPanel; -import wiiusej.utils.ButtonsEventPanel; -import wiiusej.utils.GForcePanel; -import wiiusej.utils.IRPanel; -import wiiusej.utils.OrientationPanel; -import wiiusej.utils.OrientationWiimoteEventPanel; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * Gui class to test WiiuseJ. - * - * @author guiguito - */ -public class WiiuseJGuiTest extends javax.swing.JFrame implements - 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() { - - public void windowOpened(WindowEvent e) { - // nothing - } - - public void windowClosing(WindowEvent e) { - // nothing - } - - public void windowClosed(WindowEvent e) { - // nothing - } - - public void windowIconified(WindowEvent e) { - // nothing - } - - public void windowDeiconified(WindowEvent e) { - // nothing - } - - public void windowActivated(WindowEvent e) { - showExpansionWiimoteButton.setEnabled(false); - showExpansionWiimoteButton.setText("Hide Nunchuk"); - } - - public void windowDeactivated(WindowEvent e) { - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Nunchuk"); - } - }; - - /** - * 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); - } - } - - /** - * 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); - } - - 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); - - } - - 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.isButtonOnePressed()) { - robot.mousePress(InputEvent.BUTTON3_MASK); - - } - if (arg0.isButtonAJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - } - if (arg0.isButtonBJustReleased()) { - robot.mouseRelease(InputEvent.BUTTON2_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.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 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 onStatusEvent(StatusEvent arg0) { - if (!isFirstStatusGot) { - if (arg0.isNunchukConnected()) { - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Nunchuk"); - expansionFrame = new NunchukGuiTest(wiimote); - expansionFrame - .setDefaultCloseOperation(NunchukGuiTest.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()) { - ((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."); - } - } - - 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(NunchukGuiTest.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; - } - } - - /** - * 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() { - - leftPanel = new javax.swing.JPanel(); - irViewPanel = new IRPanel(); - jTabbedPane1 = new javax.swing.JTabbedPane(); - accelerationPanel = new AccelerationWiimoteEventPanel(); - motionSensingPanel = new OrientationWiimoteEventPanel(); - gForcePanel = new wiiusej.utils.GForceWiimoteEventPanel(); - rightPanel = new javax.swing.JPanel(); - fixedWiimotePanel = new javax.swing.JPanel(); - buttonsPanel = new ButtonsEventPanel(); - controlsPanel = new javax.swing.JPanel(); - activateRumbleIRPanel = new javax.swing.JPanel(); - toggleRumbleButton = new javax.swing.JButton(); - toggleIRTrackingButton = new javax.swing.JButton(); - activateMotionSensingPanel = new javax.swing.JPanel(); - toggleMotionSensingTrackingButton = new javax.swing.JButton(); - activateSmoothingContinuousPanel = new javax.swing.JPanel(); - toggleSmoothingButton = new javax.swing.JButton(); - toggleContinuousButton = new javax.swing.JButton(); - setLedsPanel = new javax.swing.JPanel(); - led1Button = new javax.swing.JButton(); - led2Button = new javax.swing.JButton(); - led3Button = new javax.swing.JButton(); - led4Button = new javax.swing.JButton(); - setLedsButton = new javax.swing.JButton(); - setAlphaSmoothingPanel = new javax.swing.JPanel(); - alphaSmoothingTextField = new javax.swing.JTextField(); - alphaSmoothingButton = new javax.swing.JButton(); - setOrientationThresholdPanel = new javax.swing.JPanel(); - orientationThresholdTextField = new javax.swing.JTextField(); - orientationThresholdButton = new javax.swing.JButton(); - setAccelerationThresholdPanel = new javax.swing.JPanel(); - accelerationThresholdTextField = new javax.swing.JTextField(); - accelerationThresholdButton = new javax.swing.JButton(); - getStatusPanel = new javax.swing.JPanel(); - getStatusButton = new javax.swing.JButton(); - batteryText = new javax.swing.JLabel(); - batteryLevelText = new javax.swing.JLabel(); - setIrSensitivyPanel = new javax.swing.JPanel(); - setIrSensitivySpinner = new javax.swing.JSpinner(); - setIrSensitivyButton = new javax.swing.JButton(); - setTimeoutButton = new javax.swing.JButton(); - setTimeoutPanel = new javax.swing.JPanel(); - normalTimeoutSpinner = new javax.swing.JSpinner(); - normalTimeoutText = new javax.swing.JLabel(); - expansionHandshakeTimeoutSpinner = new javax.swing.JSpinner(); - expansionHandshakeTimeoutText = new javax.swing.JLabel(); - setIRConfPanel = new javax.swing.JPanel(); - toggleSensorBarPositionButton = new javax.swing.JButton(); - toggleScreenAspectRatioButton = new javax.swing.JButton(); - setVirtualResolutionPanel = new javax.swing.JPanel(); - xLabel = new javax.swing.JLabel(); - xResolutionTextField = new javax.swing.JTextField(); - yLabel = new javax.swing.JLabel(); - yResolutionTextField = new javax.swing.JTextField(); - setVirtualResolutionButton = new javax.swing.JButton(); - startMouseControlPanel = new javax.swing.JPanel(); - mouseIRControlButton = new javax.swing.JButton(); - exPansionPanel = new javax.swing.JPanel(); - expansionText = new javax.swing.JLabel(); - showExpansionWiimoteButton = new javax.swing.JButton(); - showExpansionWiimoteButton.setEnabled(false); - messagesPanel = new javax.swing.JPanel(); - reconnectWiimotesButton = new javax.swing.JButton(); - messageLabelText = new javax.swing.JLabel(); - messageText = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("WiiuseJ Test GUI"); - setName("WiiuseJ Test GUI"); // NOI18N - - leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - irViewPanel.setBackground(new java.awt.Color(0, 0, 0)); - irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( - new javax.swing.border.LineBorder(new java.awt.Color(0, 153, - 153), 2, true), "IR View", - javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, - javax.swing.border.TitledBorder.DEFAULT_POSITION, - new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, - 51))); - irViewPanel.setToolTipText("IREvent"); - - javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout( - irViewPanel); - irViewPanel.setLayout(irViewPanelLayout); - irViewPanelLayout.setHorizontalGroup(irViewPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 272, Short.MAX_VALUE)); - irViewPanelLayout.setVerticalGroup(irViewPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 299, Short.MAX_VALUE)); - - accelerationPanel.setToolTipText("MotionSensingEvent"); - - javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout( - accelerationPanel); - accelerationPanel.setLayout(accelerationPanelLayout); - accelerationPanelLayout.setHorizontalGroup(accelerationPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE)); - accelerationPanelLayout.setVerticalGroup(accelerationPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE)); - - jTabbedPane1.addTab("Acceleration", accelerationPanel); - - javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout( - motionSensingPanel); - motionSensingPanel.setLayout(motionSensingPanelLayout); - motionSensingPanelLayout.setHorizontalGroup(motionSensingPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE)); - motionSensingPanelLayout.setVerticalGroup(motionSensingPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE)); - - jTabbedPane1.addTab("Orientation", motionSensingPanel); - - javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout( - gForcePanel); - gForcePanel.setLayout(gForcePanelLayout); - gForcePanelLayout.setHorizontalGroup(gForcePanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 279, Short.MAX_VALUE)); - gForcePanelLayout.setVerticalGroup(gForcePanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 213, Short.MAX_VALUE)); - - jTabbedPane1.addTab("GForce", gForcePanel); - - javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout( - leftPanel); - leftPanel.setLayout(leftPanelLayout); - leftPanelLayout.setHorizontalGroup(leftPanelLayout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addComponent( - irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jTabbedPane1, - javax.swing.GroupLayout.DEFAULT_SIZE, 284, - Short.MAX_VALUE)); - leftPanelLayout - .setVerticalGroup(leftPanelLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, - leftPanelLayout - .createSequentialGroup() - .addComponent( - jTabbedPane1, - javax.swing.GroupLayout.PREFERRED_SIZE, - 238, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent( - irViewPanel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))); - - jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation"); - - rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, - javax.swing.BoxLayout.LINE_AXIS)); - - fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767)); - fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setPreferredSize(new java.awt.Dimension(120, 100)); - fixedWiimotePanel.setRequestFocusEnabled(false); - fixedWiimotePanel.setLayout(null); - - buttonsPanel.setMaximumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setMinimumSize(new java.awt.Dimension(120, 484)); - buttonsPanel.setOpaque(false); - buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484)); - - javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout( - buttonsPanel); - buttonsPanel.setLayout(buttonsPanelLayout); - buttonsPanelLayout.setHorizontalGroup(buttonsPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 120, Short.MAX_VALUE)); - buttonsPanelLayout.setVerticalGroup(buttonsPanelLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 484, Short.MAX_VALUE)); - - fixedWiimotePanel.add(buttonsPanel); - buttonsPanel.setBounds(0, 0, 120, 484); - - rightPanel.add(fixedWiimotePanel); - - controlsPanel.setMinimumSize(new java.awt.Dimension(100, 264)); - controlsPanel.setPreferredSize(new java.awt.Dimension(190, 264)); - controlsPanel.setLayout(new java.awt.GridLayout(16, 1)); - - toggleRumbleButton.setText("Activate Rumble"); - toggleRumbleButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleRumbleButtonMousePressed(evt); - } - }); - activateRumbleIRPanel.add(toggleRumbleButton); - - toggleIRTrackingButton.setText("Activate IR Tracking"); - toggleIRTrackingButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleIRTrackingButtonMousePressed(evt); - } - }); - activateRumbleIRPanel.add(toggleIRTrackingButton); - - controlsPanel.add(activateRumbleIRPanel); - - toggleMotionSensingTrackingButton - .setText("Activate motion sensing Tracking"); - toggleMotionSensingTrackingButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleMotionSensingTrackingButtonMousePressed(evt); - } - }); - activateMotionSensingPanel.add(toggleMotionSensingTrackingButton); - - controlsPanel.add(activateMotionSensingPanel); - - toggleSmoothingButton.setText("Activate Smoothing"); - toggleSmoothingButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSmoothingButtonMousePressed(evt); - } - }); - activateSmoothingContinuousPanel.add(toggleSmoothingButton); - - toggleContinuousButton.setText("Activate Continuous"); - toggleContinuousButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleContinuousButtonMousePressed(evt); - } - }); - activateSmoothingContinuousPanel.add(toggleContinuousButton); - - controlsPanel.add(activateSmoothingContinuousPanel); - - led1Button.setText("Led1"); - led1Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led1ButtonMousePressed(evt); - } - }); - setLedsPanel.add(led1Button); - - led2Button.setText("Led2"); - led2Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led2ButtonMousePressed(evt); - } - }); - setLedsPanel.add(led2Button); - - led3Button.setText("Led3"); - led3Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led3ButtonMousePressed(evt); - } - }); - setLedsPanel.add(led3Button); - - led4Button.setText("Led4"); - led4Button.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - led4ButtonMousePressed(evt); - } - }); - setLedsPanel.add(led4Button); - - setLedsButton.setText("Set leds"); - setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setLedsButtonMousePressed(evt); - } - }); - setLedsPanel.add(setLedsButton); - - controlsPanel.add(setLedsPanel); - - alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20)); - alphaSmoothingTextField - .setPreferredSize(new java.awt.Dimension(100, 20)); - setAlphaSmoothingPanel.add(alphaSmoothingTextField); - - alphaSmoothingButton.setText("Set alpha smoothing"); - alphaSmoothingButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - alphaSmoothingButtonMousePressed(evt); - } - }); - setAlphaSmoothingPanel.add(alphaSmoothingButton); - - controlsPanel.add(setAlphaSmoothingPanel); - - orientationThresholdTextField.setMinimumSize(new java.awt.Dimension( - 100, 20)); - orientationThresholdTextField.setPreferredSize(new java.awt.Dimension( - 100, 20)); - setOrientationThresholdPanel.add(orientationThresholdTextField); - - orientationThresholdButton.setText("Set orientation threshold"); - orientationThresholdButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - orientationThresholdButtonMousePressed(evt); - } - }); - setOrientationThresholdPanel.add(orientationThresholdButton); - - controlsPanel.add(setOrientationThresholdPanel); - - accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension( - 100, 20)); - setAccelerationThresholdPanel.add(accelerationThresholdTextField); - - accelerationThresholdButton.setText("Set acceleration threshold"); - accelerationThresholdButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - accelerationThresholdButtonMousePressed(evt); - } - }); - setAccelerationThresholdPanel.add(accelerationThresholdButton); - - controlsPanel.add(setAccelerationThresholdPanel); - - getStatusButton.setText("Get status"); - getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - getStatusButtonMousePressed(evt); - } - }); - getStatusPanel.add(getStatusButton); - - batteryText.setFont(new java.awt.Font("Tahoma", 0, 14)); - batteryText.setText("Battery level :"); - getStatusPanel.add(batteryText); - - batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14)); - batteryLevelText.setText(" %"); - getStatusPanel.add(batteryLevelText); - - controlsPanel.add(getStatusPanel); - - setIrSensitivySpinner.setPreferredSize(new java.awt.Dimension(50, 18)); - setIrSensitivySpinner - .addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - setIrSensitivySpinnerStateChanged(evt); - } - }); - setIrSensitivyPanel.add(setIrSensitivySpinner); - - setIrSensitivyButton.setText("SetIrSensivity"); - setIrSensitivyButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setIrSensitivyButtonMousePressed(evt); - } - }); - setIrSensitivyPanel.add(setIrSensitivyButton); - - setTimeoutButton.setText("Set timeouts in ms"); - setTimeoutButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setTimeoutButtonMousePressed(evt); - } - }); - setIrSensitivyPanel.add(setTimeoutButton); - - controlsPanel.add(setIrSensitivyPanel); - - normalTimeoutSpinner.setPreferredSize(new java.awt.Dimension(40, 18)); - normalTimeoutSpinner - .addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - normalTimeoutSpinnerStateChanged(evt); - } - }); - setTimeoutPanel.add(normalTimeoutSpinner); - - normalTimeoutText.setText("Normal timeout"); - setTimeoutPanel.add(normalTimeoutText); - - expansionHandshakeTimeoutSpinner - .setPreferredSize(new java.awt.Dimension(40, 18)); - expansionHandshakeTimeoutSpinner - .addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - expansionHandshakeTimeoutSpinnerStateChanged(evt); - } - }); - setTimeoutPanel.add(expansionHandshakeTimeoutSpinner); - - expansionHandshakeTimeoutText.setText("Expansion handshake timeout"); - setTimeoutPanel.add(expansionHandshakeTimeoutText); - - controlsPanel.add(setTimeoutPanel); - - toggleSensorBarPositionButton.setText("Set sensor bar above"); - toggleSensorBarPositionButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleSensorBarPositionButtonMousePressed(evt); - } - }); - setIRConfPanel.add(toggleSensorBarPositionButton); - - toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3"); - toggleScreenAspectRatioButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - toggleScreenAspectRatioButtonMousePressed(evt); - } - }); - setIRConfPanel.add(toggleScreenAspectRatioButton); - - controlsPanel.add(setIRConfPanel); - - xLabel.setText("X"); - setVirtualResolutionPanel.add(xLabel); - - xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - setVirtualResolutionPanel.add(xResolutionTextField); - - yLabel.setText("Y"); - setVirtualResolutionPanel.add(yLabel); - - yResolutionTextField.setFocusTraversalPolicyProvider(true); - yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20)); - yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20)); - setVirtualResolutionPanel.add(yResolutionTextField); - - setVirtualResolutionButton.setText("Set virtual resolution"); - setVirtualResolutionButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - setVirtualResolutionButtonMousePressed(evt); - } - }); - setVirtualResolutionPanel.add(setVirtualResolutionButton); - - controlsPanel.add(setVirtualResolutionPanel); - - mouseIRControlButton.setText("Start infrared mouse control"); - mouseIRControlButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - mouseIRControlButtonMousePressed(evt); - } - }); - startMouseControlPanel.add(mouseIRControlButton); - - controlsPanel.add(startMouseControlPanel); - - expansionText.setText("No expansion connected."); - exPansionPanel.add(expansionText); - - showExpansionWiimoteButton.setText("No expansion connected"); - showExpansionWiimoteButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - showExpansionWiimoteButtonMousePressed(evt); - } - }); - exPansionPanel.add(showExpansionWiimoteButton); - - controlsPanel.add(exPansionPanel); - - reconnectWiimotesButton.setText("Reconnect wiimote"); - reconnectWiimotesButton - .addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent evt) { - reconnectWiimotesButtonMousePressed(evt); - } - }); - messagesPanel.add(reconnectWiimotesButton); - - messageLabelText.setFont(new java.awt.Font("Tahoma", 0, 14)); - messageLabelText.setText("Message : "); - messagesPanel.add(messageLabelText); - - messageText.setFont(new java.awt.Font("Arial", 0, 14)); - messageText.setText("None"); - messagesPanel.add(messageText); - - controlsPanel.add(messagesPanel); - - rightPanel.add(controlsPanel); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout( - getContentPane()); - getContentPane().setLayout(layout); - layout - .setHorizontalGroup(layout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - layout - .createSequentialGroup() - .addComponent( - leftPanel, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent( - rightPanel, - javax.swing.GroupLayout.DEFAULT_SIZE, - 498, Short.MAX_VALUE))); - layout.setVerticalGroup(layout.createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING).addComponent( - leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, - 573, Short.MAX_VALUE)); - - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit() - .getScreenSize(); - 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 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 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 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 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 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 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 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 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 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 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 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 reconnectWiimotesButtonMousePressed( - java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed - // stop manager - WiiUseApiManager.shutdown(); - - // unregister previous wiimote - if (wiimote != null) { - onDisconnectionEvent(null); - } - - // Reset Gui - // remove frame for expansion - if (expansionFrame != null) { - if (expansionFrame instanceof NunchukGuiTest) { - ((NunchukGuiTest) 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); - - // get wiimote - Wiimote[] listWiimote = WiiUseApiManager.getWiimotes(1, true); - if (listWiimote != null && listWiimote.length > 0) { - wiimote = listWiimote[0]; - - // registers listeners - registerListeners(); - initWiimote(); - - 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); - showExpansionWiimoteButton.setText("Hide Nunchuk"); - messageText.setText("Nunchuk displayed !"); - } else {// already being shown - expansionFrame.setEnabled(false); - expansionFrame.setVisible(false); - showExpansionWiimoteButton.setEnabled(true); - showExpansionWiimoteButton.setText("Show Nunchuk"); - messageText.setText("Nunchuk hidden !"); - } - } - }// GEN-LAST:event_showExpansionWiimoteButtonMousePressed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel accelerationPanel; - private javax.swing.JButton accelerationThresholdButton; - private javax.swing.JTextField accelerationThresholdTextField; - private javax.swing.JPanel activateMotionSensingPanel; - private javax.swing.JPanel activateRumbleIRPanel; - private javax.swing.JPanel activateSmoothingContinuousPanel; - private javax.swing.JButton alphaSmoothingButton; - private javax.swing.JTextField alphaSmoothingTextField; - private javax.swing.JLabel batteryLevelText; - private javax.swing.JLabel batteryText; - private javax.swing.JPanel buttonsPanel; - private javax.swing.JPanel controlsPanel; - private javax.swing.JPanel exPansionPanel; - private javax.swing.JSpinner expansionHandshakeTimeoutSpinner; - private javax.swing.JLabel expansionHandshakeTimeoutText; - private javax.swing.JLabel expansionText; - private javax.swing.JPanel fixedWiimotePanel; - private javax.swing.JPanel gForcePanel; - private javax.swing.JButton getStatusButton; - private javax.swing.JPanel getStatusPanel; - private javax.swing.JPanel irViewPanel; - private javax.swing.JTabbedPane jTabbedPane1; - private javax.swing.JButton led1Button; - private javax.swing.JButton led2Button; - private javax.swing.JButton led3Button; - private javax.swing.JButton led4Button; - private javax.swing.JPanel leftPanel; - private javax.swing.JLabel messageLabelText; - private javax.swing.JLabel messageText; - private javax.swing.JPanel messagesPanel; - private javax.swing.JPanel motionSensingPanel; - private javax.swing.JButton mouseIRControlButton; - private javax.swing.JSpinner normalTimeoutSpinner; - private javax.swing.JLabel normalTimeoutText; - private javax.swing.JButton orientationThresholdButton; - private javax.swing.JTextField orientationThresholdTextField; - private javax.swing.JButton reconnectWiimotesButton; - private javax.swing.JPanel rightPanel; - private javax.swing.JPanel setAccelerationThresholdPanel; - private javax.swing.JPanel setAlphaSmoothingPanel; - private javax.swing.JPanel setIRConfPanel; - private javax.swing.JButton setIrSensitivyButton; - private javax.swing.JPanel setIrSensitivyPanel; - private javax.swing.JSpinner setIrSensitivySpinner; - private javax.swing.JButton setLedsButton; - private javax.swing.JPanel setLedsPanel; - private javax.swing.JPanel setOrientationThresholdPanel; - private javax.swing.JButton setTimeoutButton; - private javax.swing.JPanel setTimeoutPanel; - private javax.swing.JButton setVirtualResolutionButton; - private javax.swing.JPanel setVirtualResolutionPanel; - private javax.swing.JButton showExpansionWiimoteButton; - private javax.swing.JPanel startMouseControlPanel; - private javax.swing.JButton toggleContinuousButton; - private javax.swing.JButton toggleIRTrackingButton; - private javax.swing.JButton toggleMotionSensingTrackingButton; - private javax.swing.JButton toggleRumbleButton; - private javax.swing.JButton toggleScreenAspectRatioButton; - private javax.swing.JButton toggleSensorBarPositionButton; - private javax.swing.JButton toggleSmoothingButton; - private javax.swing.JLabel xLabel; - private javax.swing.JTextField xResolutionTextField; - private javax.swing.JLabel yLabel; - private javax.swing.JTextField yResolutionTextField; - // End of variables declaration//GEN-END:variables -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationExpansionEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/AccelerationExpansionEventPanel.java deleted file mode 100644 index cb3021f..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationExpansionEventPanel.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.RawAcceleration; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; - -/** - * Panel to display Acceleration in a MotionSensingEvent from an expansion. - * - * @author guiguito - */ -public class AccelerationExpansionEventPanel extends AccelerationPanel { - - @Override - public RawAcceleration getRawAccelerationValue(GenericEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukMotionSensingEvent() - .getRawAcceleration(); - } - return null; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/AccelerationPanel.java deleted file mode 100644 index 6caa3b6..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationPanel.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; - -import wiiusej.values.RawAcceleration; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This panel is used to watch raw acceleration values from a - * MotionSensingEvent. - * - * @author guiguito - */ -public abstract class AccelerationPanel extends javax.swing.JPanel implements - 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(); - - /** 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(); - } - - @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; - - g2.setPaint(lineColor); - g2.drawLine(0, yLine, getWidth(), yLine); - - 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; - } - - // 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); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } - - public void onIrEvent(IREvent arg0) { - // nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } - - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } - - 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 Color getBackgroundColor() { - return backgroundColor; - } - - public Color getLineColor() { - return lineColor; - } - - public Color getXColor() { - return xColor; - } - - public Color getYColor() { - return yColor; - } - - public Color getZColor() { - return zColor; - } - - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } - - public void setXColor(Color xColor) { - this.xColor = xColor; - } - - public void setYColor(Color yColor) { - this.yColor = yColor; - } - - public void setZColor(Color zColor) { - this.zColor = zColor; - } - - public void clearView() { - values.clear(); - repaint(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationWiimoteEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/AccelerationWiimoteEventPanel.java deleted file mode 100644 index 4e716de..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/AccelerationWiimoteEventPanel.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.RawAcceleration; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; - -/** - * Panel to display Acceleration in a MotionSensingEvent from a wiimote. - * @author guiguito - */ -public class AccelerationWiimoteEventPanel extends AccelerationPanel { - - @Override - public RawAcceleration getRawAccelerationValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getRawAcceleration(); - } - return null; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/ButtonsEventPanel.java deleted file mode 100644 index ba01ef4..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/ButtonsEventPanel.java +++ /dev/null @@ -1,363 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.Toolkit; -import java.awt.geom.AffineTransform; - -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This panel is used to see what buttons are pressed on the wiimote. It - * displays the result of last ButtonsEvent. - * - * @author guiguito - */ -public class ButtonsEventPanel extends javax.swing.JPanel implements - 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; - - /** - * 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); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - 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"); - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13); - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - // offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - // draw buttons pushed - g2.drawImage(wiimoteImage, 0, 0, this); - g2.setTransform(new AffineTransform()); - - if (buttons != null) { - /* button ONE */ - if (buttons.isButtonOneJustPressed()) { - drawFunction(g2, pressedColor, 53, 353); - } - if (buttons.isButtonOneHeld()) { - drawFunction(g2, heldColor, 53, 353); - } - if (buttons.isButtonOneJustReleased()) { - drawFunction(g2, releasedColor, 53, 353); - } - - /* button TWO */ - if (buttons.isButtonTwoJustPressed()) { - drawFunction(g2, pressedColor, 53, 395); - } - if (buttons.isButtonTwoHeld()) { - drawFunction(g2, heldColor, 53, 395); - } - if (buttons.isButtonTwoJustReleased()) { - drawFunction(g2, releasedColor, 53, 395); - } - - /* button A */ - if (buttons.isButtonAJustPressed()) { - drawFunction(g2, pressedColor, 53, 150); - } - if (buttons.isButtonAHeld()) { - drawFunction(g2, heldColor, 53, 150); - } - if (buttons.isButtonAJustReleased()) { - drawFunction(g2, releasedColor, 53, 150); - } - - /* button B */ - if (buttons.isButtonBJustPressed()) { - drawFunction(g2, pressedColor, 16, 149); - } - if (buttons.isButtonBHeld()) { - drawFunction(g2, heldColor, 16, 149); - } - if (buttons.isButtonBJustReleased()) { - drawFunction(g2, releasedColor, 16, 149); - } - - /* button LEFT */ - if (buttons.isButtonLeftJustPressed()) { - drawFunction(g2, pressedColor, 33, 77); - } - if (buttons.isButtonLeftHeld()) { - drawFunction(g2, heldColor, 33, 77); - } - if (buttons.isButtonLeftJustReleased()) { - drawFunction(g2, releasedColor, 33, 77); - } - - /* button RIGHT */ - if (buttons.isButtonRightJustPressed()) { - drawFunction(g2, pressedColor, 73, 77); - } - if (buttons.isButtonRightHeld()) { - drawFunction(g2, heldColor, 73, 77); - } - if (buttons.isButtonRightJustReleased()) { - drawFunction(g2, releasedColor, 73, 77); - } - - /* button UP */ - if (buttons.isButtonUpJustPressed()) { - drawFunction(g2, pressedColor, 54, 60); - } - if (buttons.isButtonUpHeld()) { - drawFunction(g2, heldColor, 54, 60); - } - if (buttons.isButtonUpJustReleased()) { - drawFunction(g2, releasedColor, 54, 60); - } - - /* button DOWN */ - if (buttons.isButtonDownJustPressed()) { - drawFunction(g2, pressedColor, 54, 97); - } - if (buttons.isButtonDownHeld()) { - drawFunction(g2, heldColor, 54, 97); - } - if (buttons.isButtonDownJustReleased()) { - drawFunction(g2, releasedColor, 54, 97); - } - - /* button MINUS */ - if (buttons.isButtonMinusJustPressed()) { - drawFunction(g2, pressedColor, 20, 230); - } - if (buttons.isButtonMinusHeld()) { - drawFunction(g2, heldColor, 20, 230); - } - if (buttons.isButtonMinusJustReleased()) { - drawFunction(g2, releasedColor, 20, 230); - } - - /* button PLUS */ - if (buttons.isButtonPlusJustPressed()) { - drawFunction(g2, pressedColor, 86, 230); - } - if (buttons.isButtonPlusHeld()) { - drawFunction(g2, heldColor, 86, 230); - } - if (buttons.isButtonPlusJustReleased()) { - drawFunction(g2, releasedColor, 86, 230); - } - - /* button HOME */ - if (buttons.isButtonHomeJustPressed()) { - drawFunction(g2, pressedColor, 53, 230); - } - if (buttons.isButtonHomeHeld()) { - drawFunction(g2, heldColor, 53, 230); - } - if (buttons.isButtonHomeJustReleased()) { - drawFunction(g2, releasedColor, 53, 230); - } - - buttons = null; - } - - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * Function used to factorize code. - * - * @param g2 - * where to draw a shape. - * @param col - * color to use. - * @param x - * x coordinates. - * @param y - * y coordinates. - */ - private void drawFunction(Graphics2D g2, Color col, int x, int y) { - g2.setPaint(col); - g2.translate(x, y); - g2.draw(shape); - g2.fill(shape); - g2.setTransform(new AffineTransform()); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this)); - buttons = arg0; - repaint(); - } - - public void onIrEvent(IREvent arg0) { - // nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } - - public void onExpansionEvent(ExpansionEvent e) { - // nothing - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - buttons = null; - repaint(); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - // nothing - } - - public Color getHeldColor() { - return heldColor; - } - - public Color getPressedColor() { - return pressedColor; - } - - public Color getReleasedColor() { - return releasedColor; - } - - public Shape getShape() { - return shape; - } - - public void setHeldColor(Color heldColor) { - this.heldColor = heldColor; - } - - public void setPressedColor(Color pressedColor) { - this.pressedColor = pressedColor; - } - - public void setReleasedColor(Color releasedColor) { - this.releasedColor = releasedColor; - } - - public void setShape(Shape shape) { - this.shape = shape; - } - - public void clearView() { - buttons = null; - repaint(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/GForceExpansionEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/GForceExpansionEventPanel.java deleted file mode 100644 index d5852b0..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/GForceExpansionEventPanel.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.GForce; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; - -/** - * Panel to display GForce in a MotionSensingEvent from an expansion. - * - * @author guiguito - */ -public class GForceExpansionEventPanel extends GForcePanel{ - - @Override - public GForce getGForceValue(GenericEvent e) { - if (e instanceof NunchukEvent){ - return ((NunchukEvent)e).getNunchukMotionSensingEvent().getGforce(); - } - return null; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/GForcePanel.java b/WiiUseJ_0.12/src/wiiusej/utils/GForcePanel.java deleted file mode 100644 index 14de5f2..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/GForcePanel.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; - -import wiiusej.values.GForce; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This panel is used to watch gravity force values from a MotionSensingEvent. - * - * @author guiguito - */ -public abstract class GForcePanel extends javax.swing.JPanel implements - 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(); - - /** - * Default constructor of the AccelerationPanel. - */ - public GForcePanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the AccelerationPanel. - * - * @param bgColor - * background color. - * @param xxColor - * color of the acceleration on X axis. - * @param yyColor - * color of the acceleration on Y axis. - * @param zzColor - * color of the acceleration on Z axis. - * @param lColor - * line color. - */ - public GForcePanel(Color bgColor, Color xxColor, Color yyColor, - Color zzColor, Color lColor) { - backgroundColor = bgColor; - xColor = xxColor; - yColor = yyColor; - zColor = zzColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - // draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - GForce[] valuesArray = values.toArray(new GForce[0]); - double unit = yMiddleFloat / 5.0; - int previousX = 0; - int previousY = 0; - int previousZ = 0; - // draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - GForce gforce = valuesArray[i]; - // draw X - g2.setPaint(xColor); - int yDelta = (int) Math.round(unit * gforce.getX()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousX, i, y); - g2.setTransform(new AffineTransform()); - previousX = y; - // draw Y - g2.setPaint(yColor); - yDelta = (int) Math.round(unit * gforce.getY()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousY, i, y); - g2.setTransform(new AffineTransform()); - previousY = y; - // draw Z - g2.setPaint(zColor); - yDelta = (int) Math.round(unit * gforce.getZ()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousZ, i, y); - g2.setTransform(new AffineTransform()); - previousZ = y; - } - - // draw legend - g2.setPaint(xColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(yColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(zColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - - g2.setPaint(lineColor); - g2.drawString("X", 30, getHeight() - 5); - g2.drawString("Y", 85, getHeight() - 5); - g2.drawString("Z", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle - 5); - g2.drawString("5", 2, 10); - g2.drawString("-5", 2, getHeight() - 15); - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } - - public void onIrEvent(IREvent arg0) { - // nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } - - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } - - private void draw(GenericEvent arg0) { - if (values.size() >= getWidth()) { - // if there are as many values as pixels in the width - // clear points - values.clear(); - } - GForce gforce = getGForceValue(arg0); - if (gforce != null) - values.add(gforce); - repaint(); - } - - public abstract GForce getGForceValue(GenericEvent e); - - public Color getBackgroundColor() { - return backgroundColor; - } - - public Color getLineColor() { - return lineColor; - } - - public Color getXColor() { - return xColor; - } - - public Color getYColor() { - return yColor; - } - - public Color getZColor() { - return zColor; - } - - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } - - public void setXColor(Color xColor) { - this.xColor = xColor; - } - - public void setYColor(Color yColor) { - this.yColor = yColor; - } - - public void setZColor(Color zColor) { - this.zColor = zColor; - } - - public void clearView() { - values.clear(); - repaint(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/GForceWiimoteEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/GForceWiimoteEventPanel.java deleted file mode 100644 index 1ae710e..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/GForceWiimoteEventPanel.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.GForce; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; - -/** - * Panel to display GForce in a MotionSensingEvent from a wiimote. - * - * @author guiguito - */ -public class GForceWiimoteEventPanel extends GForcePanel { - - @Override - public GForce getGForceValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getGforce(); - } - return null; - } -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/IRPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/IRPanel.java deleted file mode 100644 index c826fee..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/IRPanel.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; - -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This panel is used to see what the IR camera of the wiimote sees. - * - * @author guiguito - */ -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; - - /** - * Default constructor for IR Panel. Background color : black. IR sources - * color : yellow. Border color of IR sources : blue. Shape of the IR - * sources : circle with a diameter of 10. - */ - public IRPanel() { - shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); - initArrays(); - initComponents(); - } - - /** - * Constructor used to parameterize the IR panel. - * - * @param bgColor - * color. - * @param ptColor - * IR sources color. - * @param bdColor - * border color of IR sources. - * @param sh - * Shape of the IR sources. - */ - public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) { - backgroundColor = bgColor; - color = ptColor; - borderColor = bdColor; - shape = sh; - initArrays(); - initComponents(); - } - - private void initArrays() { - xCoordinates = new int[MAX_NB_POINTS]; - yCoordinates = new int[MAX_NB_POINTS]; - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - // draw points - int i = 0; - while (i < nbPoints) { - double x = xCoordinates[i]; - double y = yCoordinates[i]; - - long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); - long yy = getHeight() - - Math.round((double) getHeight() * y / 768.0); - g2.translate(xx, yy); - - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(color); - g2.fill(shape); - - g2.setTransform(new AffineTransform()); - i++; - } - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - repaint(); - } - - public void onIrEvent(IREvent arg0) { - // transfer points - wiiusej.values.IRSource[] points = arg0.getIRPoints(); - nbPoints = points.length; - for (int i = 0; i < points.length; i++) { - xCoordinates[i] = (int) points[i].getRx(); - yCoordinates[i] = (int) points[i].getRy(); - } - for (int i = points.length; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - - // redraw panel - repaint(); - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } - - public void onExpansionEvent(ExpansionEvent e) { - // nothing - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // clear previous points - for (int i = 0; i < MAX_NB_POINTS; i++) { - xCoordinates[i] = -1; - yCoordinates[i] = -1; - } - // redraw panel - repaint(); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent e) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent e) { - // nothing - } - - public Color getBackgroundColor() { - return backgroundColor; - } - - public Color getBorderColor() { - return borderColor; - } - - public Color getColor() { - return color; - } - - public Shape getShape() { - return shape; - } - - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public void setBorderColor(Color borderColor) { - this.borderColor = borderColor; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setShape(Shape shape) { - this.shape = shape; - } - - public void clearView() { - initArrays(); - repaint(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/JoystickEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/JoystickEventPanel.java deleted file mode 100644 index 6f04ce6..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/JoystickEventPanel.java +++ /dev/null @@ -1,231 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.JoystickEvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * Panel to display joystick events. - * - * @author guiguito - */ -public abstract class JoystickEventPanel extends javax.swing.JPanel implements - 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; - - /** Creates new form JoystickPanel */ - public JoystickEventPanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the JoystickPanel. - * - * @param bgColor - * background color. - * @param pColor - * point color. - * @param bdColor - * border color for the shape. - * @param sh - * shape of what is drawn. - */ - public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor, - Shape sh) { - backgroundColor = bgColor; - pointColor = pColor; - shape = sh; - borderColor = bdColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2.setTransform(new AffineTransform()); - - // compute center - int xCenter = (int) Math.round(d.getWidth() / 2.0); - int yCenter = (int) Math.round(d.getHeight() / 2.0); - - // compute coordinates - if (lastJoystickEvent != null) { - double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI - / 180.0) - * lastJoystickEvent.getMagnitude(); - double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI - / 180.0) - * lastJoystickEvent.getMagnitude(); - int dx = (int) Math.round(shape.getBounds().getWidth() / 2); - int dy = (int) Math.round(shape.getBounds().getHeight() / 2); - double xTemp = xAng * (xCenter - dx * 2); - double yTemp = yAng * (yCenter - dy * 2); - int x = xCenter - dx + (int) xTemp; - int y = yCenter - dy - (int) yTemp; - // System.out.println("--------------------------------------------------------------------"); - // System.out.println(lastJoystickEvent); - // System.out.println("xCenter ,yCenter : "+xCenter+" , "+yCenter); - // System.out.println("xAng, yAng : "+xAng+" , "+yAng); - // System.out.println("dx, dy : "+dx+" , "+dy); - // System.out.println("xTemp, yTemp : "+xTemp+" , "+yTemp); - // System.out.println("x, y : "+x+" , "+y); - // shape - g2.translate(x, y); - g2.setPaint(borderColor); - g2.draw(shape); - g2.setPaint(pointColor); - g2.fill(shape); - } - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } - - public void onIrEvent(IREvent arg0) { - // nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - // nothing - } - - public void onExpansionEvent(ExpansionEvent arg0) { - JoystickEvent joy = getJoystikEvent(arg0); - if (joy != null) { - lastJoystickEvent = joy; - } - repaint(); - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // nothing - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } - - public Color getBackgroundColor() { - return backgroundColor; - } - - public Color getPointColor() { - return pointColor; - } - - public Color getBorderColor() { - return borderColor; - } - - public Shape getShape() { - return shape; - } - - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public void setPointColor(Color pointColor) { - this.pointColor = pointColor; - } - - public void setBorderColor(Color borderColor) { - this.borderColor = borderColor; - } - - public void setShape(Shape shape) { - this.shape = shape; - } - - public abstract JoystickEvent getJoystikEvent(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() { - - 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/WiiUseJ_0.12/src/wiiusej/utils/NunchukJoystickEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/NunchukJoystickEventPanel.java deleted file mode 100644 index a534751..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/NunchukJoystickEventPanel.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.JoystickEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; - -/** - * Panel to display nunchuk joystick events. - * - * @author guiguito - */ -public class NunchukJoystickEventPanel extends JoystickEventPanel { - - @Override - public JoystickEvent getJoystikEvent(ExpansionEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukJoystickEvent(); - } - return null; - } -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/OrientationExpansionEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/OrientationExpansionEventPanel.java deleted file mode 100644 index f5e3856..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/OrientationExpansionEventPanel.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.Orientation; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; - -/** - * Panel to display Orientation in a MotionSensingEvent from an expansion. - * - * @author guiguito - */ -public class OrientationExpansionEventPanel extends OrientationPanel { - - @Override - public Orientation getOrientationValue(GenericEvent e) { - if (e instanceof NunchukEvent) { - return ((NunchukEvent) e).getNunchukMotionSensingEvent() - .getOrientation(); - } - return null; - } -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/OrientationPanel.java deleted file mode 100644 index b298911..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/OrientationPanel.java +++ /dev/null @@ -1,283 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.util.ArrayList; - -import wiiusej.values.Orientation; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.utils.WiimoteListener; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This panel is used to watch orientation values from a MotionSensingEvent. - * - * @author guiguito - */ -public abstract class OrientationPanel extends javax.swing.JPanel implements - 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(); - - /** - * Default constructor. Background color : White. Roll color : Red. Pitch - * color : Green. Yaw color : Blue. - */ - public OrientationPanel() { - initComponents(); - } - - /** - * Constructor used to choose the colors used by the OrientationPanel. - * - * @param bgColor - * background color. - * @param rColor - * roll color. - * @param pColor - * pitch color. - * @param yColor - * yaw color. - * @param lColor - * line color. - */ - public OrientationPanel(Color bgColor, Color rColor, Color pColor, - Color yColor, Color lColor) { - backgroundColor = bgColor; - rollColor = rColor; - pitchColor = pColor; - yawColor = yColor; - lineColor = lColor; - initComponents(); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Dimension d = getSize(); - checkOffScreenImage(); - Graphics offG = mImage.getGraphics(); - offG.setColor(backgroundColor); - offG.fillRect(0, 0, d.width, d.height); - Graphics2D g2 = (Graphics2D) mImage.getGraphics(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - // draw medium line - double yMiddleFloat = getHeight() / 2.0; - int yMiddle = (int) Math.round(yMiddleFloat); - - g2.setPaint(lineColor); - g2.drawLine(0, yMiddle, getWidth(), yMiddle); - - Orientation[] valuesArray = values.toArray(new Orientation[0]); - double unit = yMiddleFloat / 180.0; - int previousRoll = 0; - int previousPitch = 0; - int previousYaw = 0; - // draw curves - for (int i = 0; i < valuesArray.length && i < getWidth(); i++) { - Orientation orientation = valuesArray[i]; - // draw roll - g2.setPaint(rollColor); - int yDelta = (int) Math.round(unit * orientation.getRoll()); - int y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousRoll, i, y); - g2.setTransform(new AffineTransform()); - previousRoll = y; - // draw pitch - g2.setPaint(pitchColor); - yDelta = (int) Math.round(unit * orientation.getPitch()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousPitch, i, y); - g2.setTransform(new AffineTransform()); - previousPitch = y; - // draw yaw - g2.setPaint(yawColor); - yDelta = (int) Math.round(unit * orientation.getYaw()); - y = -1 * yDelta + yMiddle; - g2.drawLine(i - 1, previousYaw, i, y); - g2.setTransform(new AffineTransform()); - previousYaw = y; - } - - // draw legend - g2.setPaint(rollColor); - g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10); - g2.setPaint(pitchColor); - g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10); - g2.setPaint(yawColor); - g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10); - - g2.setPaint(lineColor); - g2.drawString("Roll", 30, getHeight() - 5); - g2.drawString("Pitch", 85, getHeight() - 5); - g2.drawString("Yaw", 145, getHeight() - 5); - g2.drawString("0", 2, yMiddle - 5); - g2.drawString("180", 2, 10); - g2.drawString("-180", 2, getHeight() - 15); - // put offscreen image on the screen - g.drawImage(mImage, 0, 0, null); - } - - /** - * check if the mImage variable has been initialized. If it's not the case - * it initializes it with the dimensions of the panel. mImage is for double - * buffering. - */ - private void checkOffScreenImage() { - Dimension d = getSize(); - if (mImage == null || mImage.getWidth(null) != d.width - || mImage.getHeight(null) != d.height) { - mImage = createImage(d.width, d.height); - } - } - - public void onButtonsEvent(WiimoteButtonsEvent arg0) { - // nothing - } - - public void onIrEvent(IREvent arg0) { - // nothing - } - - public void onMotionSensingEvent(MotionSensingEvent arg0) { - draw(arg0); - } - - public void onExpansionEvent(ExpansionEvent arg0) { - draw(arg0); - } - - public void onStatusEvent(StatusEvent arg0) { - // nothing - } - - public void onDisconnectionEvent(DisconnectionEvent arg0) { - // Clear points. - values.clear(); - repaint(); - } - - public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) { - // nothing - } - - public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) { - // nothing - } - - private void draw(GenericEvent arg0) { - if (values.size() >= getWidth()) { - // if there are as many values as pixels in the width - // clear points - values.clear(); - } - Orientation orientation = getOrientationValue(arg0); - if (orientation != null) - values.add(orientation); - repaint(); - } - - public abstract Orientation getOrientationValue(GenericEvent e); - - public Color getBackgroundColor() { - return backgroundColor; - } - - public Color getLineColor() { - return lineColor; - } - - public Color getPitchColor() { - return pitchColor; - } - - public Color getRollColor() { - return rollColor; - } - - public Color getYawColor() { - return yawColor; - } - - public void setBackgroundColor(Color backgroundColor) { - this.backgroundColor = backgroundColor; - } - - public void setLineColor(Color lineColor) { - this.lineColor = lineColor; - } - - public void setPitchColor(Color pitchColor) { - this.pitchColor = pitchColor; - } - - public void setRollColor(Color rollColor) { - this.rollColor = rollColor; - } - - public void setYawColor(Color yawColor) { - this.yawColor = yawColor; - } - - public void clearView() { - values.clear(); - repaint(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //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 -} diff --git a/WiiUseJ_0.12/src/wiiusej/utils/OrientationWiimoteEventPanel.java b/WiiUseJ_0.12/src/wiiusej/utils/OrientationWiimoteEventPanel.java deleted file mode 100644 index e38f3c9..0000000 --- a/WiiUseJ_0.12/src/wiiusej/utils/OrientationWiimoteEventPanel.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.utils; - -import wiiusej.values.Orientation; -import wiiusej.wiiusejevents.GenericEvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; - -/** - * Panel to display Orientation in a MotionSensingEvent from a wiimote. - * - * @author guiguito - */ -public class OrientationWiimoteEventPanel extends OrientationPanel { - - @Override - public Orientation getOrientationValue(GenericEvent e) { - if (e instanceof MotionSensingEvent) { - return ((MotionSensingEvent) e).getOrientation(); - } - return null; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/values/GForce.java b/WiiUseJ_0.12/src/wiiusej/values/GForce.java deleted file mode 100644 index da79ed2..0000000 --- a/WiiUseJ_0.12/src/wiiusej/values/GForce.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents gravity force on each axis. - * - * @author guiguito - */ -public class GForce { - - private float x; - private float y; - private float z; - - /** - * 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; - } - - /** - * @return the x - */ - public float getX() { - return x; - } - - /** - * @return the y - */ - public float getY() { - return y; - } - - /** - * @return the z - */ - public float getZ() { - return z; - } - - @Override - public String toString() { - return "Gravity force : (" + x + ", " + y + "," + z + ")"; - } -} diff --git a/WiiUseJ_0.12/src/wiiusej/values/IRSource.java b/WiiUseJ_0.12/src/wiiusej/values/IRSource.java deleted file mode 100644 index a738c05..0000000 --- a/WiiUseJ_0.12/src/wiiusej/values/IRSource.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class used for IR sources. - * - * @author guiguito - */ -public class IRSource { - - 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; - } - - /** - * 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 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 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 + ")"; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/values/Orientation.java b/WiiUseJ_0.12/src/wiiusej/values/Orientation.java deleted file mode 100644 index 124d890..0000000 --- a/WiiUseJ_0.12/src/wiiusej/values/Orientation.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Class that represents the orientation of the wiimote. - * - * @author guiguito - */ -public class Orientation { - - 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; - } - - /** - * 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 pitch (can be smoothed). - * - * @return the pitch - */ - public float getPitch() { - return pitch; - } - - /** - * 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 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 + ")"; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/values/RawAcceleration.java b/WiiUseJ_0.12/src/wiiusej/values/RawAcceleration.java deleted file mode 100644 index 83f9578..0000000 --- a/WiiUseJ_0.12/src/wiiusej/values/RawAcceleration.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.values; - -/** - * Represents raw acceleration on each axis. - * - * @author guiguito - */ -public class RawAcceleration { - - private short x; - private short y; - private short z; - - /** - * 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; - } - - /** - * @return the x - */ - public short getX() { - return x; - } - - /** - * @return the y - */ - public short getY() { - return y; - } - - /** - * @return the z - */ - public short getZ() { - return z; - } - - @Override - public String toString() { - return "Raw acceleration : (" + x + ", " + y + "," + z + ")"; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/GenericEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/GenericEvent.java deleted file mode 100644 index 18d8429..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/GenericEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents; - -/** - * Abstract mother class representing an event with a wiimote id. - * - * @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(); -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java deleted file mode 100644 index d9705fa..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ButtonsEvent.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -import wiiusej.wiiusejevents.GenericEvent; - -/** - * Class which represents a buttons event. - * - * @author guiguito - */ -public abstract class ButtonsEvent extends GenericEvent { - - /* 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); - } - - /** - * 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 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; - } - - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ - - protected boolean buttonTest(short buttonBitsDefinition, short buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } - - protected boolean isButtonJustPressed(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } - - protected boolean isButtonJustReleased(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } - - protected boolean isButtonHeld(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } - - protected boolean isButtonPressed(short 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; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java deleted file mode 100644 index 868f33c..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -import wiiusej.wiiusejevents.GenericEvent; - -/** - * Mother Class of all expansions event. - * - * @author guiguito - */ -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(); - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/IREvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/IREvent.java deleted file mode 100644 index 1873a8c..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/IREvent.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -import wiiusej.values.IRSource; -import wiiusej.wiiusejevents.GenericEvent; - -/** - * Class which represents an IR event. - * - * @author guiguito - */ -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; - - 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 - - /** - * 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() { - return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints); - } - - /** - * 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 Y coordinate. - * - * @return the y - */ - public int getY() { - return y; - } - - /** - * 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 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 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 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 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 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; - } - - /** - * 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; - } - - @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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java deleted file mode 100644 index 5dc7f2f..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -import wiiusej.wiiusejevents.GenericEvent; - -/** - * Class that stores values on a joystick Event. - * - * @author guiguito - */ -public class JoystickEvent extends GenericEvent { - - 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; - } - - /** - * 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; - } - - /** - * Maximum joystick values. - * - * @return the max - */ - public short[] getMax() { - return max; - } - - /** - * Minimum joystick values. - * - * @return the min - */ - public short[] getMin() { - return min; - } - - /** - * 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; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java deleted file mode 100644 index 0945a48..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -import wiiusej.values.GForce; -import wiiusej.values.Orientation; -import wiiusej.values.RawAcceleration; -import wiiusej.wiiusejevents.GenericEvent; - -/** - * Class which represents a motion sensing event. - * - * @author guiguito - */ -public class MotionSensingEvent extends GenericEvent { - - /* 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; - - /** - * 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); - } - - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * 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 orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } - - /** - * Get acceleration threshold. - * - * @return the accelerationThreshold - */ - public int getAccelerationThreshold() { - return accelerationThreshold; - } - - /** - * 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; - } - - @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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java deleted file mode 100644 index b6584d6..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -/** - * Class which represents a buttons event for a generic event. It means buttons - * from a wiimote. - * - * @author guiguito - */ -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; - - /** - * Constructor of the nunchuk button 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 */ - - public boolean isButtonZJustPressed() { - return isButtonJustPressed(NUNCHUK_BUTTON_Z); - } - - public boolean isButtonZJustReleased() { - return isButtonJustReleased(NUNCHUK_BUTTON_Z); - } - - public boolean isButtonZeHeld() { - return isButtonHeld(NUNCHUK_BUTTON_Z); - } - - public boolean isButtonZPressed() { - return isButtonPressed(NUNCHUK_BUTTON_Z); - } - - /* Button Z */ - - public boolean isButtonCJustPressed() { - return isButtonJustPressed(NUNCHUK_BUTTON_C); - } - - public boolean isButtonCJustReleased() { - return isButtonJustReleased(NUNCHUK_BUTTON_C); - } - - public boolean isButtonCHeld() { - return isButtonHeld(NUNCHUK_BUTTON_C); - } - - public boolean isButtonCPressed() { - return isButtonPressed(NUNCHUK_BUTTON_C); - } - - @Override - public String toString() { - return "/******** Buttons for Nunchuk Event ********/\n" - + super.toString(); - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java deleted file mode 100644 index eec7b97..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -/** - * This class represents the values from the joystick and its events. - * - * @author guiguito - */ -public class NunchukEvent extends ExpansionEvent { - - NunchukButtonsEvent buttonsEvent; - MotionSensingEvent nunchukMotionSensingEvent; - 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); - } - - /** - * 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; - } - - /** - * Get joystick buttons event. - * - * @return the joystick 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 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; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java deleted file mode 100644 index 106fc1c..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/physicalevents/WiimoteButtonsEvent.java +++ /dev/null @@ -1,267 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.physicalevents; - -/** - * Class which represents a buttons event for a generic event. It means buttons - * from a wiimote. - * - * @author guiguito - */ -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; - - /** - * 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 */ - - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOnePressed() { - return isButtonPressed(WIIMOTE_BUTTON_ONE); - } - - /* Button TWO */ - - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoPressed() { - return isButtonPressed(WIIMOTE_BUTTON_TWO); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAPressed() { - return isButtonPressed(WIIMOTE_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBPressed() { - return isButtonPressed(WIIMOTE_BUTTON_B); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftPressed() { - return isButtonPressed(WIIMOTE_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightPressed() { - return isButtonPressed(WIIMOTE_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpPressed() { - return isButtonPressed(WIIMOTE_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownPressed() { - return isButtonPressed(WIIMOTE_BUTTON_DOWN); - } - - /* Button - */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_MINUS); - } - - /* Button + */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusPressed() { - return isButtonPressed(WIIMOTE_BUTTON_PLUS); - } - - /* Button HOME */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomePressed() { - return isButtonPressed(WIIMOTE_BUTTON_HOME); - } - - @Override - public String toString() { - return "/******** Buttons for Wiimote generic Event ********/\n" - + super.toString(); - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/EventsGatherer.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/EventsGatherer.java deleted file mode 100644 index 31ed13a..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/EventsGatherer.java +++ /dev/null @@ -1,355 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.utils; - -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; -import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; -import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent; - -/** - * This class is used to gather events during a call to the Wiiuse API. - * - * @author guiguito - */ -public class EventsGatherer { - - 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]; - } - - /** - * 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 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); - } - } - - /** - * 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 . - * - * @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); - } - } - - /** - * 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 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 NunchukRemovedEvent to the gatherer. - * - * @param id - * id of the wiimote. - */ - public void addNunchukRemovedEvent(int id) { - NunchukRemovedEvent evt = new NunchukRemovedEvent(id); - addEvent(evt); - } - - /** - * Return an array containing the events. - * - * @return events received. - */ - public WiiUseApiEvent[] getEvents() { - return java.util.Arrays.copyOfRange(events, 0, index); - } - - /** - * 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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java deleted file mode 100644 index ee1ce80..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.utils; - -import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; - -/** - * This is the interface to implement to listen to events from the wiiuse API. - * - * @author guiguito - */ -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); - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiimoteListener.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiimoteListener.java deleted file mode 100644 index d066516..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/utils/WiimoteListener.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.utils; - -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; -import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent; -import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; - -/** - * This is the interface to implement to listen to events from wiimotes. The - * differents methods are called in this order : onButtonsEvent, onIrEvent, - * onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent - * onNunchukInsertedEvent, onNunchukRemovedEvent. - * - * @author guiguito - */ -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 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 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); - - /** - * 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 NunchukRemovedEvent occurs. - * - * @param e - * the NunchukRemovedEvent. - */ - void onNunchukRemovedEvent(NunchukRemovedEvent e); -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java deleted file mode 100644 index 1c844c7..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -/** - * Class representing a disconnection event. - * - * @author guiguito - */ -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); - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" - + super.getWiimoteId() + " ********/\n"; - return out; - } - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java deleted file mode 100644 index 6aff636..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -/** - * Event that represents the connection of a nunchuk to a wiimote. - * - * @author guiguito - * - */ -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); - } - - /* - * (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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java deleted file mode 100644 index c9c585d..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -/** - * Event that represents the connection of a nunchuk to a wiimote. - * - * @author guiguito - */ -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); - } - - /* - * (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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java deleted file mode 100644 index d200bb7..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java +++ /dev/null @@ -1,293 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -/** - * Class used to represent a status event. This class is used to know what are - * the settings of the wiimote. - * - * @author guiguito - */ -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; - - /* 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; - - /* Status variables */ - private boolean connected = false; - - private float batteryLevel = -1; - - private short leds = 0; - - private boolean isSpeakerEnabled = false; - - private int attachment = 0; - - private boolean isRumbleActive = false; - - private boolean isContinuousActive = false; - - private boolean isIrActive = 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); - } - - /** - * 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; - } - - /** - * 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; - } - - /** - * 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 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 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; - } - - /** - * 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; - } - - /** - * 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; - } - - /** - * 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 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; - } - - @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/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java deleted file mode 100644 index 0527b13..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -import wiiusej.wiiusejevents.GenericEvent; - -/** - * This class describes the structure of an event from the WiiUse API event. - * - * @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(); - -} diff --git a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java b/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java deleted file mode 100644 index 04c1840..0000000 --- a/WiiUseJ_0.12/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * This file is part of WiiuseJ. - * - * WiiuseJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * WiiuseJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WiiuseJ. If not, see . - */ -package wiiusej.wiiusejevents.wiiuseapievents; - -import wiiusej.wiiusejevents.physicalevents.ExpansionEvent; -import wiiusej.wiiusejevents.physicalevents.IREvent; -import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; -import wiiusej.wiiusejevents.physicalevents.NunchukEvent; -import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent; - -/** - * Class that is a bean to be filled by the wiiuse API on an event that occurs - * on a wiimote. - * - * @author guiguito - */ -public class WiimoteEvent extends WiiUseApiEvent { - - WiimoteButtonsEvent buttonsEvent = null; - IREvent infraredEvent = null; - MotionSensingEvent motionSensingEvent = null; - 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 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 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; - } - - /** - * 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 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; - } - - /** - * 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); - } - - /** - * 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); - } - - public void setClassicControllerEvent() { - // @TODO - } - - @Override - public String toString() { - String out = ""; - /* Status */ - out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId() - + " ********/\n"; - - out += buttonsEvent; - - 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 (expansionEvent != null) { - out += expansionEvent; - } else { - out += "/******** Expansion ********/\n"; - out += "--- No expansion connected \n"; - } - - return out; - } - -} diff --git a/WiiUseJ_0.12/wiiuse.dll b/WiiUseJ_0.12/wiiuse.dll deleted file mode 100644 index a7e228c..0000000 Binary files a/WiiUseJ_0.12/wiiuse.dll and /dev/null differ diff --git a/tag1/WiiUseJ/.classpath b/tag1/WiiUseJ/.classpath deleted file mode 100644 index d171cd4..0000000 --- a/tag1/WiiUseJ/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/tag1/WiiUseJ/.project b/tag1/WiiUseJ/.project deleted file mode 100644 index 9485f4a..0000000 --- a/tag1/WiiUseJ/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - WiiUseJava - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/tag1/WiiUseJ/libWiiuseJ.dll b/tag1/WiiUseJ/libWiiuseJ.dll deleted file mode 100644 index e38a95c..0000000 Binary files a/tag1/WiiUseJ/libWiiuseJ.dll and /dev/null differ diff --git a/tag1/WiiUseJ/src/tests/LedsTask.java b/tag1/WiiUseJ/src/tests/LedsTask.java deleted file mode 100644 index d4adda2..0000000 --- a/tag1/WiiUseJ/src/tests/LedsTask.java +++ /dev/null @@ -1,30 +0,0 @@ -package tests; - -import java.util.TimerTask; - -import wiiusej.WiiUseApiManager; - -public class LedsTask extends TimerTask { - - private int i = 0; - private int inc = 1; - - @Override - public void run() { - if(i==0){ - WiiUseApiManager.getInstance().setLeds(1, true, false, false, false); - }else if(i==1){ - WiiUseApiManager.getInstance().setLeds(1, false, true, false, false); - }else if(i==2){ - WiiUseApiManager.getInstance().setLeds(1, false, false, true, false); - }else if(i==3){ - WiiUseApiManager.getInstance().setLeds(1, false, false, false, true); - } - if (i==0) i=1; - if (i==3) i=-1; - i = i+inc; - - } - -} - diff --git a/tag1/WiiUseJ/src/tests/Tests.java b/tag1/WiiUseJ/src/tests/Tests.java deleted file mode 100644 index c5a1ce4..0000000 --- a/tag1/WiiUseJ/src/tests/Tests.java +++ /dev/null @@ -1,388 +0,0 @@ -package tests; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.InputEvent; -import wiiusej.Point2DInteger; -import wiiusej.WiiMoteEvent; -import wiiusej.WiiUseApiListener; -import wiiusej.WiiUseApiManager; -import wiiusej.Wiimote; -import wiiusej.WiimoteListener; - -/** - * This class used to test this API. - * - * @author gduche - * - */ -public class Tests implements WiimoteListener { - - Robot robot; - - private static int DISPLAY_EACH_VALUE = 1; - private static int DUMP = 2; - private static int MOVE_MOUSE = 3; - private static int ORIENT_THRESH_CONT = 4; - private static int TEST_LEDS = 5; - - private Wiimote wiimote; - - int dump = DISPLAY_EACH_VALUE; - - public Tests(Wiimote wim) { - wiimote = wim; - wiimote.addWiiMoteEventListeners(this); - try { - robot = new Robot(); - } catch (AWTException e) { - e.printStackTrace(); - } - } - - @Override - public void wiimoteEvent(WiiMoteEvent e) { - - if (dump == DISPLAY_EACH_VALUE) { - if (e.isConnected()) { - // 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 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 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 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 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 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.isButtonMinusJustPressed() && e.isButtonPlusJustPressed()) { - 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 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(); - } - - /* display status */ - if (e.getBatteryLevel() != -1) { - System.out - .println("battery level : " + e.getBatteryLevel()); - System.out.println("= --- Leds : " + e.getLeds() + "\n"); - System.out.println("= --- Rumble : " + e.isRumbleActive() - + "\n"); - System.out.println("= --- Continous : " - + e.isContinuousActive() + "\n"); - System.out.println("= --- Smoothing : " - + e.isSmoothingActive() + "\n"); - System.out.println("= --- Speaker : " - + e.isSpeakerEnabled() + "\n"); - System.out.println("= --- Attachment : " - + e.isThereAttachment() + "\n"); - } - - /* display ir points */ - if (e.isIrActive()) { - Point2DInteger[] list = e.getIRPoints(); - for (int i = 0; i < list.length; i++) { - if (list[i] != null) - System.out.print("Point :(" + list[i].getX() + "," - + list[i].getY() + ") "); - } - System.out.println(""); - } - - /* display motion sensing */ - if (e.isMotionSensingActive()) { - System.out.println("Motion Sensing :" + e.getOrientation() - + " , " + e.getGforce()); - } - - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - } else { - System.out.println(" WIIMOTE ID : " + e.getWiimoteId() - + " DISCONNECTED !!!!!"); - wiimote.disconnect(); - } - } else if (dump == DUMP) { - System.out.println(e); - /* Activate all */ - if (e.isButtonAJustPressed()) { - System.out.println("IR Activated"); - wiimote.activateIRTRacking(); - wiimote.activateMotionSensing(); - wiimote.activateRumble(); - } - if (e.isButtonBJustPressed()) { - System.out.println("IR 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(); - } - - /* 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); - } - - Point2DInteger[] list = e.getIRPoints(); - if (e.isIrActive() && list[0] != null) { - - 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); - } - - /* leave test */ - if (e.isButtonHomeJustPressed()) { - System.out.println("LEAVING TEST"); - wiimote.disconnect(); - } - } else if (dump == ORIENT_THRESH_CONT) { - wiimote.activateMotionSensing(); - if (e.isButtonOneJustPressed()) { - System.out.println("Continous activated"); - wiimote.activateContinuous(); - } - if (e.isButtonTwoJustPressed()) { - System.out.println("Continous deactivated"); - wiimote.deactivateContinuous(); - } - if (e.isButtonAJustPressed()) { - System.out.println("Smoothing activated"); - wiimote.activateSmoothing(); - } - if (e.isButtonBJustPressed()) { - System.out.println("Smoothing deactivated"); - wiimote.deactivateSmoothing(); - } - if (e.isButtonPlusJustPressed()) { - System.out.println("Threshold orientation 10 degrees"); - wiimote.setOrientationThreshold(10); - } - if (e.isButtonMinusJustPressed()) { - System.out.println("Threshold orientation 0.5 degrees"); - wiimote.setOrientationThreshold((float) 0.5); - } - System.out.println(e); - - /* 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(); - } - } - } - - /** - * @param args - */ - public static void main(String[] args) { - Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(); - if (wiimotes.length>0){ - System.out.println(wiimotes[0]); - Tests tests = 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); - - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/GForce.java b/tag1/WiiUseJ/src/wiiusej/GForce.java deleted file mode 100644 index 3cd513d..0000000 --- a/tag1/WiiUseJ/src/wiiusej/GForce.java +++ /dev/null @@ -1,81 +0,0 @@ -package wiiusej; - -/** - * Represents gravity force on each axis. - * @author gduche - * - */ -public class GForce { - - private float x; - private float y; - private float z; - - /** - * 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; - } - - /** - * @return the x - */ - public float getX() { - return x; - } - - /** - * @param x the x to set - */ - public void setX(float x) { - this.x = x; - } - - /** - * @return the y - */ - public float getY() { - return y; - } - - /** - * @param y the y to set - */ - public void setY(float y) { - this.y = y; - } - - /** - * @return the z - */ - public float getZ() { - return z; - } - - /** - * @param z the z to set - */ - public void setZ(float z) { - this.z = z; - } - - @Override - public String toString() { - return "Gravity force : ("+x+", "+y+","+z+")"; - } -} diff --git a/tag1/WiiUseJ/src/wiiusej/LedsRequest.java b/tag1/WiiUseJ/src/wiiusej/LedsRequest.java deleted file mode 100644 index c068ba3..0000000 --- a/tag1/WiiUseJ/src/wiiusej/LedsRequest.java +++ /dev/null @@ -1,109 +0,0 @@ -package wiiusej; - -/** - * Represents a request to set leds of the wiimote with WiiUse API. - * @author gduche - * - */ -public class LedsRequest extends wiiusej.WiiUseApiRequest { - - private boolean led1, led2, led3, led4; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - */ - public LedsRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * id of the wiimote concerned - * @param type - * type of the request - * @param l1 - * led1 status. True=ON, False=OFF - * @param l2 - * led2 status. True=ON, False=OFF - * @param l3 - * led3 status. True=ON, False=OFF - * @param l4 - * led4 status. True=ON, False=OFF - */ - public LedsRequest(int id, int type, boolean l1, boolean l2, boolean l3, - boolean l4) { - super(id, type); - led1 = l1; - led2 = l2; - led3 = l3; - led4 = l4; - } - - /** - * @return the led1 - */ - public boolean isLed1() { - return led1; - } - - /** - * @param led1 - * the led1 to set - */ - public void setLed1(boolean led1) { - this.led1 = led1; - } - - /** - * @return the led2 - */ - public boolean isLed2() { - return led2; - } - - /** - * @param led2 - * the led2 to set - */ - public void setLed2(boolean led2) { - this.led2 = led2; - } - - /** - * @return the led3 - */ - public boolean isLed3() { - return led3; - } - - /** - * @param led3 - * the led3 to set - */ - public void setLed3(boolean led3) { - this.led3 = led3; - } - - /** - * @return the led4 - */ - public boolean isLed4() { - return led4; - } - - /** - * @param led4 - * the led4 to set - */ - public void setLed4(boolean led4) { - this.led4 = led4; - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/OrientThresholdRequest.java b/tag1/WiiUseJ/src/wiiusej/OrientThresholdRequest.java deleted file mode 100644 index 0d3cc14..0000000 --- a/tag1/WiiUseJ/src/wiiusej/OrientThresholdRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -package wiiusej; - -/** - * Represents a request to set orientation Threshold in Wiiuse API. - * Orientation Threshold is the minimum angle (in degrees) between two events. - * @author gduche - * - */ -public class OrientThresholdRequest extends WiiUseApiRequest { - - private float thresholhd; - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - */ - public OrientThresholdRequest(int id, int type) { - super(id, type); - } - - /** - * Constructor setting the id of the wiimote concerned. - * - * @param id - * the id of the wiimote concerned. - * @param type - * type of the request - * @param th - * threshold in degrees - */ - public OrientThresholdRequest(int id, int type, float th) { - super(id, type); - thresholhd = th; - } - - /** - * @return the thresholhd - */ - public float getThresholhd() { - return thresholhd; - } - - /** - * @param thresholhd the thresholhd to set - */ - public void setThresholhd(float thresholhd) { - this.thresholhd = thresholhd; - } - - - -} diff --git a/tag1/WiiUseJ/src/wiiusej/Orientation.java b/tag1/WiiUseJ/src/wiiusej/Orientation.java deleted file mode 100644 index 52ebd7c..0000000 --- a/tag1/WiiUseJ/src/wiiusej/Orientation.java +++ /dev/null @@ -1,77 +0,0 @@ -package wiiusej; - -/** - * Class that represents the orientation of the wiimote. - * @author gduche - * - */ -public class Orientation { - - private float roll; - private float pitch; - private float yaw; - - /** - * Default constructor. - */ - public Orientation(){ - roll = 0; - pitch = 0; - yaw = 0; - } - - /** - * Contructor with raw, pitch , yaw. - * @param r raw - * @param p pitch - * @param y yaw - */ - public Orientation(float r, float p, float y){ - roll = r; - pitch = p; - yaw = y; - } - - /** - * @return the roll - */ - public float getRoll() { - return roll; - } - /** - * @param roll the roll to set - */ - public void setRoll(float roll) { - this.roll = roll; - } - /** - * @return the pitch - */ - public float getPitch() { - return pitch; - } - /** - * @param pitch the pitch to set - */ - public void setPitch(float pitch) { - this.pitch = pitch; - } - /** - * @return the yaw - */ - public float getYaw() { - return yaw; - } - /** - * @param yaw the yaw to set - */ - public void setYaw(float yaw) { - this.yaw = yaw; - } - - @Override - public String toString() { - return "Orientation : (roll: "+roll+", pitch: "+pitch+", yaw: "+yaw+")"; - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/Point2DInteger.java b/tag1/WiiUseJ/src/wiiusej/Point2DInteger.java deleted file mode 100644 index f2f9181..0000000 --- a/tag1/WiiUseJ/src/wiiusej/Point2DInteger.java +++ /dev/null @@ -1,35 +0,0 @@ -package wiiusej; - -import java.awt.geom.Point2D; - -public class Point2DInteger extends Point2D { - private int x; - private int y; - - public Point2DInteger(int xx, int yy) { - super(); - setLocation(xx,yy); - } - - @Override - public double getX() { - return x; - } - - @Override - public double getY() { - return y; - } - - @Override - public void setLocation(double xx, double yy) { - this.x = (int)xx; - this.y = (int)yy; - } - - @Override - public String toString() { - return "("+x+","+y+")"; - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiiMoteEvent.java b/tag1/WiiUseJ/src/wiiusej/WiiMoteEvent.java deleted file mode 100644 index 8e2ee7c..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiiMoteEvent.java +++ /dev/null @@ -1,624 +0,0 @@ -package wiiusej; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Class that is a bean to be filled by the wiiuse API. - * - * @author gduche - * - */ -public class WiiMoteEvent { - - /* 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; - - private static short WIIMOTE_LED_1 = 1; - private static short WIIMOTE_LED_2 = 2; - private static short WIIMOTE_LED_3 = 4; - private static short WIIMOTE_LED_4 = 8; - - private static short NB_LEDS = 4; - - /* ID */ - private int wiimoteId = -1; - - /* Status variables */ - private boolean connected = false; - - private float batteryLevel = -1; - - private short leds = 0; - - private boolean isSpeakerEnabled = false; - - private boolean isThereAttachment = false; - - private boolean isRumbleActive = false; - - private float orientationThreshold = 0; - - private boolean isContinuousActive = false; - - private boolean isSmoothingActive = false; - - /* Buttons */ - private short buttonsJustPressed = 0; - private short buttonsJustReleased = 0; - private short buttonsHeld = 0; - - /* IR Tracking */ - private boolean isIrActive = false; - private Point2DInteger[] IRPoints; - - /* Motion Sensing */ - private boolean isMotionSensingActive = false; - private Orientation orientation; - private GForce gforce; - - /** - * Default constructor - */ - public WiiMoteEvent() { - // init IRPoints array - IRPoints = new Point2DInteger[NB_LEDS]; - } - - /** - * Construct the Wiimote setting up the id. - * - * @param id - * the Wiimote id - */ - public WiiMoteEvent(int id) { - this(); - 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; - } - - /** - * True if the wiimote is connected false otherwise. - * - * @return return the connected status. - */ - public boolean isConnected() { - return connected; - } - - /** - * Set the connected value to true. - */ - void setConnected() { - this.connected = true; - } - - /** - * Set the connected value to false. - */ - void setDisconnected() { - this.connected = false; - } - - /** - * 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; - } - - /** - * Tell if the speaker is enable for this wiimote - * - * @return TRUE if it enabled false otherwise - */ - public boolean isSpeakerEnabled() { - return isSpeakerEnabled; - } - - /** - * Tell if there is an attachment to the Wiimote - * - * @return TRUE if it there is one false otherwise - */ - public boolean isThereAttachment() { - return isThereAttachment; - } - - /** - * Set battery level, leds, speaker state and attachment in one method. - * These method is called (and those variables are filled) only when a - * status has been requested on this wiimote. - * - * @param batt - * battery level - * @param led - * status of leds - * @param speak - * speakers status - * @param attach - * attachment status - */ - void setBatteryLedsSpeakerAttachment(float batt, short led, boolean speak, - boolean attach) { - this.batteryLevel = batt; - this.leds = led; - this.isSpeakerEnabled = speak; - this.isThereAttachment = attach; - } - - /** - * Get the status of rumble. - * - * @return true if the rumble is active false otherwise - */ - public boolean isRumbleActive() { - return isRumbleActive; - } - - /** - * Set Rumble flag to Inactive. - */ - void setRumbleInactive() { - this.isRumbleActive = false; - } - - /** - * Get orientation threshold. - * - * @return the orientationThreshold - */ - public float getOrientationThreshold() { - return orientationThreshold; - } - - /** - * Tell if the CONTINUOUS option is activated. - * - * @return the isContinuousActive - */ - public boolean isContinuousActive() { - return isContinuousActive; - } - - /** - * Tell if the option SMOOTHING is activated. - * - * @return the isSmoothingActive - */ - public boolean isSmoothingActive() { - return isSmoothingActive; - } - - /** - * 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 held - * - * @return the short storing the buttons held - */ - public short getButtonsHeld() { - return buttonsHeld; - } - - /** - * Set all buttons in one method. - * - * @param buttonsJustPressed - * @param buttonsJustReleased - * @param buttonsHeld - */ - void setAllButtons(short buttonsJustPressed, short buttonsJustReleased, - short buttonsHeld) { - this.buttonsJustPressed = buttonsJustPressed; - this.buttonsJustReleased = buttonsJustReleased; - this.buttonsHeld = buttonsHeld; - } - - /** - * Tell if the IR Tracking is active. - * - * @return TRUE if it is active or false otherwise. - */ - public boolean isIrActive() { - return isIrActive; - } - - /** - * Get list of IR points. - * - * @return the list of 2D points - */ - public Point2DInteger[] getIRPoints() { - return IRPoints; - } - - /** - * Add IR Point in the list (Max 4 points) - * - * @param x - * x value - * @param y - * y value - */ - void addIRpoint(int x, int y) { - for (int i = 0; i < IRPoints.length; i++) { - if (IRPoints[i] == null) { - IRPoints[i] = new Point2DInteger(x, y); - return; - } - } - return; - } - - /** - * Clear IR points. - */ - void EmptyIRPoints() { - for (int i = 0; i < IRPoints.length; i++) { - IRPoints[i] = null; - } - } - - /** - * 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; - } - - /** - * Set status variables always filled during an event. - * - * @param id - * id of the wiimote - * @param connect - * true if the wiimote is connected - * @param irState - * true if ir is active - * @param rumbleState - * true if rumble is active - * @param motionSensingState - * true if accelerometer is active - * @param orientationThreshold - * value of the minimum angle between two events with the - * accelerometer - * @param continuousState - * true if continuous flag is activated - * @param smoothingState - * true if smoothing flag is activated - */ - void setPermanentStatus(int id, boolean connect, boolean irState, - boolean rumbleState, boolean motionSensingState, - float orientationThreshold, boolean continuousState, - boolean smoothingState) { - wiimoteId = id; - connected = connect; - isIrActive = irState; - isRumbleActive = rumbleState; - isMotionSensingActive = motionSensingState; - this.orientationThreshold = orientationThreshold; - isContinuousActive = continuousState; - isSmoothingActive = smoothingState; - } - - /** - * @return the orientation - */ - public Orientation getOrientation() { - return orientation; - } - - /** - * Get the gravity force. - * - * @return the gforce - */ - public GForce getGforce() { - return gforce; - } - - /** - * Set orientation and gravity force. - * - * @param r - * roll - * @param p - * pitch - * @param ya - * yaw - * @param x - * gravity force on x axis - * @param y - * gravity force on y axis - * @param z - * gravity force on z axis - */ - void setOrientationAndGforce(float r, float p, float ya, float x, float y, - float z) { - this.orientation = new Orientation(r, p, ya); - this.gforce = new GForce(x, y, z); - } - - /** **************** BUTTONS Methods ***************** */ - /* generic button functions */ - - private boolean buttonTest(short buttonBitsDefinition, short buttons) { - return (buttons & buttonBitsDefinition) == buttonBitsDefinition; - } - - private boolean isButtonJustPressed(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustPressed) - && !isButtonHeld(buttonBitsDefinition); - } - - private boolean isButtonJustReleased(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsJustReleased); - } - - private boolean isButtonHeld(short buttonBitsDefinition) { - return buttonTest(buttonBitsDefinition, buttonsHeld); - } - - /* Button ONE */ - - public boolean isButtonOneJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_ONE); - } - - public boolean isButtonOneHeld() { - return isButtonHeld(WIIMOTE_BUTTON_ONE); - } - - /* Button TWO */ - - public boolean isButtonTwoJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_TWO); - } - - public boolean isButtonTwoHeld() { - return isButtonHeld(WIIMOTE_BUTTON_TWO); - } - - /* Button A */ - - public boolean isButtonAJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_A); - } - - public boolean isButtonAHeld() { - return isButtonHeld(WIIMOTE_BUTTON_A); - } - - /* Button B */ - - public boolean isButtonBJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_B); - } - - public boolean isButtonBHeld() { - return isButtonHeld(WIIMOTE_BUTTON_B); - } - - /* Button LEFT */ - - public boolean isButtonLeftJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_LEFT); - } - - public boolean isButtonLeftHeld() { - return isButtonHeld(WIIMOTE_BUTTON_LEFT); - } - - /* Button RIGHT */ - - public boolean isButtonRightJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT); - } - - public boolean isButtonRightHeld() { - return isButtonHeld(WIIMOTE_BUTTON_RIGHT); - } - - /* Button UP */ - - public boolean isButtonUpJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_UP); - } - - public boolean isButtonUpHeld() { - return isButtonHeld(WIIMOTE_BUTTON_UP); - } - - /* Button DOWN */ - - public boolean isButtonDownJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_DOWN); - } - - public boolean isButtonDownHeld() { - return isButtonHeld(WIIMOTE_BUTTON_DOWN); - } - - /* Button - */ - - public boolean isButtonMinusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_MINUS); - } - - public boolean isButtonMinusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_MINUS); - } - - /* Button + */ - - public boolean isButtonPlusJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_PLUS); - } - - public boolean isButtonPlusHeld() { - return isButtonHeld(WIIMOTE_BUTTON_PLUS); - } - - /* Button HOME */ - - public boolean isButtonHomeJustPressed() { - return isButtonJustPressed(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeJustReleased() { - return isButtonJustReleased(WIIMOTE_BUTTON_HOME); - } - - public boolean isButtonHomeHeld() { - return isButtonHeld(WIIMOTE_BUTTON_HOME); - } - - @Override - public String toString() { - super.toString(); - String out = ""; - /* Status */ - out += "/*********** WIIMOTE ID :" + wiimoteId + " ********/\n"; - out += "--- connected : " + connected + "\n"; - out += "--- Battery level : " + batteryLevel + "\n"; - out += "--- Leds : " + leds + "\n"; - out += "--- Speaker enabled : " + isSpeakerEnabled + "\n"; - out += "--- Attachment ? : " + isThereAttachment + "\n"; - out += "--- Rumble ? : " + isRumbleActive + "\n"; - out += "--- Orientation threshold value ? : " + orientationThreshold - + "\n"; - out += "--- Continuous ? : " + isContinuousActive + "\n"; - out += "--- Smoothing ? : " + isSmoothingActive + "\n"; - /* Display buttons */ - out += "/******** Buttons ********/\n"; - out += "--- Buttons just pressed : " + buttonsJustPressed + "\n"; - out += "--- Buttons just released : " + buttonsJustReleased + "\n"; - out += "--- Buttons held : " + buttonsHeld + "\n"; - - /* Display IR Tracking */ - out += "/******** IR Tracking ********/\n"; - out += "--- Active : " + isIrActive + "\n"; - if (isIrActive) { - out += "--- Seen points\n"; - for (int i = 0; i < IRPoints.length; i++) { - if (IRPoints[i] != null) { - out += IRPoints[i].toString(); - } - } - } - - /* Motion sensing */ - out += "/******** Motion sensing ********/\n"; - out += "--- Motion sensing : " + isMotionSensingActive + "\n"; - if (isMotionSensingActive) { - out += "--- " + orientation + "\n"; - out += "--- " + gforce + "\n"; - } - return out; - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiiUseApi.java b/tag1/WiiUseJ/src/wiiusej/WiiUseApi.java deleted file mode 100644 index 091f269..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiiUseApi.java +++ /dev/null @@ -1,174 +0,0 @@ -package wiiusej; - -/** - * Singleton used to manipulate WiiUse Api. - * @author gduche - * - */ -public class WiiUseApi { - - static { - System.loadLibrary("libWiiuseJ"); - } - - private static WiiUseApi instance = new WiiUseApi(); - - /** - * Get the only instance of WiiUseApi. - * @return - */ - static WiiUseApi getInstance(){ - return instance; - } - - /** - * Load the library. - * - * @return 0 if there is an error, 1 if everything is ok. - */ - native int loadLibrary(); - - /** - * Try to connect to 2 wiimotes. Make them rumble to show they are - * connected. - * - * @return 0 if there is an error otherwise it returns the number of - * wiimotes connected. - */ - native int doConnections(); - - /** - * Close connection to the wiimote with the given id. - * - */ - native void closeConnection(int id); - - /** - * Shutdown Wiiuse API. - * @return 0 if there is an error, 1 if everything is ok. - */ - native void shutdownApi(); - - /** - * Activate rumble on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateRumble(int id); - - /** - * Deactivate rumble on the wiimote with the given id. - * - * @param id the id of the wiimote. - */ - native void deactivateRumble(int id); - - /** - * Activate IR Tracking on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateIRTracking(int id); - - /** - * Deactivate IR Tracking on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void deactivateIRTracking(int id); - - /** - * Activate motion sensing on the wiimote with the given id. - * @param id the id of the wiimote. - */ - native void activateMotionSensing(int id); - - /** - * Deactivate motion sensing on the wiimote with the given id. - * @param id the id of the wiimote. - */ - 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 - */ - 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 - */ - native void setOrientThreshold(int id, float angle); - - /** - * Make the the accelerometers give smoother results. - * This is set by default. - * @param id the id of the wiimote concerned - */ - native void activateSmoothing(int id); - - /** - * Make the the accelerometers give raw results. - * @param id the id of the wiimote concerned - */ - 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 - */ - native void activateContinuous(int id); - - /** - * Make the wiimote generate an event only when there is one. - * @param id the id of the wiimote concerned - */ - native void deactivateContinuous(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. - */ - native void getStatus(int id); - - /** - * Get status and values from the wiimotes and send it through callbacks. - * - * @param mote The WiimoteEvent object to fill with the datas. - */ - native void specialPoll(WiiMoteEvent mote); - - - /* Tests */ - public static void main(String[] args) { - - /* Test JNI Side */ - WiiUseApi manager = new WiiUseApi(); - - int value = manager.loadLibrary(); - System.out.println("loadLibrary : " + value); - - value = manager.doConnections(); - System.out.println("doConnections : " + value); - - WiiMoteEvent mote = new WiiMoteEvent(); - - manager.getStatus(1); - System.out.println("Status : \n" + mote); - - System.out.println(""); - System.out.println("!!!!!!!!!!!!!! Polling !!!!!!!!!"); - while (true) { - manager.specialPoll(mote); - System.out.println(mote); - mote.EmptyIRPoints(); - } - // manager.closeConnectionsAndShutDown(); - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiiUseApiListener.java b/tag1/WiiUseJ/src/wiiusej/WiiUseApiListener.java deleted file mode 100644 index 81f3792..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiiUseApiListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package wiiusej; - - - -public interface WiiUseApiListener extends java.util.EventListener { - - void wiimoteEvent(WiiMoteEvent e); - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiiUseApiManager.java b/tag1/WiiUseJ/src/wiiusej/WiiUseApiManager.java deleted file mode 100644 index 7ab9825..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiiUseApiManager.java +++ /dev/null @@ -1,430 +0,0 @@ -package wiiusej; - -import java.util.ArrayList; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.swing.event.EventListenerList; - -/** - * Class that manage the use of Wiiuse API. - * - * @author gduche - * - */ -public class WiiUseApiManager extends Thread { - - private static WiiUseApiManager instance = new WiiUseApiManager(); - - private final EventListenerList listeners = new EventListenerList(); - - private Wiimote[] wiimotes; - - private WiiUseApi wiiuse = WiiUseApi.getInstance(); - - private boolean loaded = false; - - private int connected = -1; - - private AtomicBoolean running = new AtomicBoolean(false); - - private ConcurrentLinkedQueue requests = new ConcurrentLinkedQueue(); - - 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. - * @return an array with connected wiimotes or NULL. - */ - public static Wiimote[] getWiimotes() { - WiiUseApiManager manager = getInstance(); - if (!manager.loaded){ - manager.loadLibrary(); - } - if (manager.connected<0){ - int nbWiimotes = manager.connectWiimotes(); - manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i=0; i 0) { - loaded = true; - return true; - } else { - loaded = false; - System.out.println("Error loading the Wiimote library !!!"); - return false; - } - } - // already loaded - return loaded; - } - - /** - * Connect wiimote and get the number of wiimotes connected. Supposed to be - * used once. - * - * @return 0 if nothing connected or the number of wiimotes connected. - */ - public int connectWiimotes() { - if (connected < 0 && loaded) { - connected = wiiuse.doConnections(); - // System.out.println(connected + " wiimote(s) connected !!!"); - 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. - */ - public void closeConnection(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST)); - } - - /** - * Get the number of wiimotes connected. - * - * @return the number of wiimotes connected. - */ - public int getNbConnectedWiimotes() { - return connected; - } - - /** - * Stop thread and shutdown wiiuse Api. - */ - public void shutdown() { - running.set(false); - loaded = false; - wiiuse.shutdownApi(); - } - - /** - * Activate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Deactivate the rumble for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateRumble(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST)); - } - - /** - * Activate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Deactivate IR Tracking for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateIRTRacking(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST)); - } - - /** - * Activate motion sensing for the wiimote with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Deactivate motion sensing for the wiimoter with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateMotionSensing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST)); - } - - /** - * Activate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Deactivate smoothing the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void deactivateSmoothing(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST)); - } - - /** - * Activate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote. - */ - public void activateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * Deactivate continuous for the wiimotes with the given id. - * - * @param id - * id of the wiimote - */ - public void deactivateContinuous(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST)); - } - - /** - * 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 - */ - public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) { - requests.add(new LedsRequest(id, WiiUseApiRequest.WIIUSE_LEDS_REQUEST, - l1, l2, l3, l4)); - } - - /** - * Set the orientation threshold for the given id. - * - * @param id - * id of the wiimote - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(int id, float th) { - requests.add(new OrientThresholdRequest(id, - WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST, th)); - } - - /** - * Get Status for the wiimote for the given id. - * - * @param id - * id of the wiimote - */ - public void getStatus(int id) { - requests.add(new WiiUseApiRequest(id, - WiiUseApiRequest.WIIUSE_STATUS_REQUEST)); - } - - @Override - public void run() { - - if (loaded && (connected > 0)) { - running.set(true); - - WiiMoteEvent evt = new WiiMoteEvent(); - - // Start polling and tell the observers when there Wiimote events - while (running.get()) { - WiiUseApiRequest req = requests.poll(); - if (req != null) {// there is a request for the wiiuse api - int id = req.getId(); - if (req.getRequestType() == WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST) { - /* Close connections requests */ - removeWiiUseApiListener(wiimotes[id]); - wiimotes[id]=null; - wiiuse.closeConnection(id); - connected--; - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) { - /* Status requests */ - wiiuse.getStatus(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST) { - /* Activate Rumble requests */ - wiiuse.activateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST) { - /* Deactivate Rumble requests */ - wiiuse.deactivateRumble(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST) { - /* Activate IR Tracking requests */ - wiiuse.activateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST) { - /* Deactivate IR Tracking requests */ - wiiuse.deactivateIRTracking(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST) { - /* Activate Motion sensing requests */ - wiiuse.activateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST) { - /* Deactivate Motion sensing requests */ - wiiuse.deactivateMotionSensing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_LEDS_REQUEST) { - /* leds requests */ - LedsRequest reqLed = (LedsRequest) req; - wiiuse.setLeds(id, reqLed.isLed1(), reqLed.isLed2(), - reqLed.isLed3(), reqLed.isLed4()); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST) { - /* Activate smoothing requests */ - wiiuse.activateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST) { - /* Deactivate smoothing requests */ - wiiuse.deactivateSmoothing(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST) { - /* Activate continuous requests */ - wiiuse.activateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST) { - /* Deactivate continuous requests */ - wiiuse.deactivateContinuous(id); - } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST) { - /* set orientation request */ - wiiuse.setOrientThreshold(req.getId(), - ((OrientThresholdRequest) req).getThresholhd()); - } else { - System.out.println("Bad request to Wiiuse API !!!!!"); - } - } - - /* Polling */ - wiiuse.specialPoll(evt); - - if (evt.getWiimoteId() != -1) {//event filled - if (!evt.isConnected()) {// check if it was a - // disconnection - connected--; - removeWiiUseApiListener(wiimotes[evt.getWiimoteId()]); - wiimotes[evt.getWiimoteId()]=null; - System.out.println("Wiimote " + evt.getWiimoteId() - + " disconnected !"); - } else {//there is an event notify observers - // not a disconnection notify listeners - notifyWiiUseApiListener(evt); - // create a new event to be filled - evt = new WiiMoteEvent(); - } - } - if (connected == 0) {// stop this thread if there is - //no more wiimotes connected. - System.out.println("No more wiimotes connected !!!"); - shutdown(); - } - } - } else { - if (!loaded) { - System.out.println("Library not Loaded !"); - } - if (connected <= 0) { - System.out.println("No wiimotes connected !"); - } - } - - } - - /** - * Add WiiUseApiListener to the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void addWiiUseApiListener(WiiUseApiListener listener) { - listeners.add(WiiUseApiListener.class, listener); - } - - /** - * Remove WiiUseApiListener from the listeners list. - * - * @param listener - * a WiiUseApiListener - */ - public void removeWiiUseApiListener(WiiUseApiListener listener) { - listeners.remove(WiiUseApiListener.class, listener); - } - - /** - * Get the list of WiiUseApiListeners. - * - * @return the list of WiiUseApiListeners. - */ - public WiiUseApiListener[] getWiiUseApiListeners() { - return listeners.getListeners(WiiUseApiListener.class); - } - - /** - * Notify WiiUseApiListeners that an event occured. - * - * @param evt - * WiimoteEvent occured - */ - private void notifyWiiUseApiListener(WiiMoteEvent evt) { - for (WiiUseApiListener listener : getWiiUseApiListeners()) { - listener.wiimoteEvent(evt); - } - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiiUseApiRequest.java b/tag1/WiiUseJ/src/wiiusej/WiiUseApiRequest.java deleted file mode 100644 index 56998c7..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiiUseApiRequest.java +++ /dev/null @@ -1,82 +0,0 @@ -package wiiusej; - -/** - * Represents a request we could do to the WiiUse API. - * @author gduche - * - */ -public class WiiUseApiRequest { - - public static int WIIUSE_STATUS_REQUEST=1; - public static int WIIUSE_ACTIVATE_SMOOTHING_REQUEST=2; - public static int WIIUSE_DEACTIVATE_SMOOTHING_REQUEST=-2; - public static int WIIUSE_ACTIVATE_IR_TRACKING_REQUEST=3; - public static int WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST=-3; - public static int WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST=4; - public static int WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST=-4; - public static int WIIUSE_CLOSE_CONNECTION_REQUEST=5; - public static int WIIUSE_ACTIVATE_CONTINUOUS_REQUEST=6; - public static int WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST=-6; - public static int WIIUSE_ACTIVATE_RUMBLE_REQUEST=7; - public static int WIIUSE_DEACTIVATE_RUMBLE_REQUEST=-7; - public static int WIIUSE_LEDS_REQUEST=8; - public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST=9; - - - private int wiimoteId=0; - private int requestType=0; - - /** - * Constructor setting the id of the wiimote concerned. - * @param id the id of the wiimote concerned. - */ - public WiiUseApiRequest(int id){ - wiimoteId = id; - } - - /** - * Constructor setting the id of the wiimote concerned. - * @param id the id of the wiimote concerned. - * - */ - public WiiUseApiRequest(int id, int type){ - wiimoteId = id; - requestType = type; - } - - /** - * Get id of the wiimote concerned by this request. - * @return id of the wiimote concerned - */ - public int getId(){ - return wiimoteId; - } - - /** - * Set id of the wiimote concerned by this request. - * @param id id fh the wiimote concernet - */ - public void setId(int id){ - wiimoteId = id; - } - - /** - * Get the request type. - * @return the requestType - */ - public int getRequestType() { - return requestType; - } - - /** - * Set the request type. - * @param requestType the requestType to set - */ - public void setRequestType(int requestType) { - this.requestType = requestType; - } - - - -} - diff --git a/tag1/WiiUseJ/src/wiiusej/Wiimote.java b/tag1/WiiUseJ/src/wiiusej/Wiimote.java deleted file mode 100644 index 5d7232e..0000000 --- a/tag1/WiiUseJ/src/wiiusej/Wiimote.java +++ /dev/null @@ -1,191 +0,0 @@ -package wiiusej; - -import javax.swing.event.EventListenerList; - -/** - * Class that represents a wiimote. - * You can register as an observer of this wiimote to listen events from it. - * You manage it. - * @author gduche - * - */ -public class Wiimote implements WiiUseApiListener { - - private int id;//wiimote id - - private EventListenerList listeners = new EventListenerList(); - - private WiiUseApiManager manager; - - - /** - * Contructor. - * @param idd id of the wiimote - * @param manager manager wo built it. - */ - public Wiimote(int idd, WiiUseApiManager manager){ - id = idd; - this.manager = manager; - } - - /** - * Disconnect this wiimote. - */ - public void disconnect(){ - deactivateIRTRacking(); - deactivateMotionSensing(); - deactivateRumble(); - manager.closeConnection(id); - } - - /** - * Activate the rumble. - */ - public void activateRumble() { - manager.activateRumble(id); - } - - /** - * Deactivate the rumble. - */ - public void deactivateRumble() { - manager.deactivateRumble(id); - } - - /** - * Activate IR Tracking. - */ - public void activateIRTRacking() { - manager.activateIRTRacking(id); - } - - /** - * Deactivate IR Tracking. - */ - public void deactivateIRTRacking() { - manager.deactivateIRTRacking(id); - } - - /** - * Activate motion sensing. - */ - public void activateMotionSensing() { - manager.activateMotionSensing(id); - } - - /** - * Deactivate motion sensing. - */ - public void deactivateMotionSensing() { - manager.deactivateMotionSensing(id); - } - - /** - * Activate smoothing. - */ - public void activateSmoothing() { - manager.activateSmoothing(id); - } - - /** - * Deactivate smoothing. - */ - public void deactivateSmoothing() { - manager.deactivateSmoothing(id); - } - - /** - * Activate continuous. - */ - public void activateContinuous() { - manager.activateContinuous(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 the orientation threshold (minimum angle between two degrees with accelerometer). - * @param th - * threshold in degrees - */ - public void setOrientationThreshold(float th) { - manager.setOrientationThreshold(id,th); - } - - /** - * Get Status of the wiimote. - */ - public void getStatus() { - manager.getStatus(id); - } - - - @Override - public void wiimoteEvent(WiiMoteEvent e) { - if (e.getWiimoteId() == id){ - notifyWiiMoteEventListeners(e); - } - } - - /** - * 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); - } - - /** - * Get the list of WiimoteListener. - * @return the list of WiimoteListener. - */ - public WiimoteListener[] getWiiMoteEventListeners() { - return listeners.getListeners(WiimoteListener.class); - } - - /** - * Notify WiimoteListener that an event occured. - * @param evt WiimoteEvent occured - */ - private void notifyWiiMoteEventListeners(WiiMoteEvent evt) { - for (WiimoteListener listener : getWiiMoteEventListeners()) { - listener.wiimoteEvent(evt); - } - } - - @Override - public String toString() { - return "Wiimote with ID : "+id; - } - -} diff --git a/tag1/WiiUseJ/src/wiiusej/WiimoteListener.java b/tag1/WiiUseJ/src/wiiusej/WiimoteListener.java deleted file mode 100644 index b0cb6cd..0000000 --- a/tag1/WiiUseJ/src/wiiusej/WiimoteListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package wiiusej; - - -public interface WiimoteListener extends java.util.EventListener { - - void wiimoteEvent(WiiMoteEvent e); - -} diff --git a/tag1/WiiUseJ/wiiuse.dll b/tag1/WiiUseJ/wiiuse.dll deleted file mode 100644 index c6ea93f..0000000 Binary files a/tag1/WiiUseJ/wiiuse.dll and /dev/null differ diff --git a/tag1/WiiUseJC/.cproject b/tag1/WiiUseJC/.cproject deleted file mode 100644 index ea50e8b..0000000 --- a/tag1/WiiUseJC/.cproject +++ /dev/null @@ -1,648 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -make - -wiiusej_WiiUseApi.c -true -true -true - - - - - - - - - diff --git a/tag1/WiiUseJC/.project b/tag1/WiiUseJC/.project deleted file mode 100644 index ef5e371..0000000 --- a/tag1/WiiUseJC/.project +++ /dev/null @@ -1,69 +0,0 @@ - - - WiiUseJavaC - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/WiiUseJavaC/Release} - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.append_environment - true - - - ?name? - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.cnature - - diff --git a/tag1/WiiUseJC/wiiuse.c b/tag1/WiiUseJC/wiiuse.c deleted file mode 100644 index 23db02f..0000000 --- a/tag1/WiiUseJC/wiiuse.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * @brief API source file - * - * The file must be linked to any third party - * program that is utilizing wiiuse as an - * external library. - */ - -#define WIIUSE_API_SRC - -#include -#include "wiiuse.h" - -#ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif - -typedef int (*entry_func_t)(struct wiiuse_api_t**); - -struct wiiuse_api_t* wiiuse_api = NULL; -void* wiiuse_mod = NULL; - -/** - * @brief Load the wiiuse library and initialize the function pointers. - * - * @param wiiuse_file The relative or absolute path to the wiiuse library file. - * - * @return The version of the wiiuse library loaded. - * - * @see wiiuse_shutdown() - * - * If the version of wiiuse being used has a different API - * version as expected, this function will fail and return 0. - */ -const char* wiiuse_startup(char* wiiuse_file) { - entry_func_t entry_func = NULL; - - if (wiiuse_api) - /* already loaded */ - return wiiuse_api->version; - - if (!wiiuse_file) - return NULL; - - /* load the module */ - wiiuse_mod = dlopen(wiiuse_file, RTLD_NOW); - - if (!wiiuse_mod) - /* can not load module */ - return NULL; - - /* get the entry point */ - entry_func = (entry_func_t)dlsym(wiiuse_mod, "wiiuse_main"); - - if (!entry_func) { - wiiuse_shutdown(); - return NULL; - } - - /* call the entry function */ - entry_func(&wiiuse_api); - - /* make sure the API versions are the same */ - if (wiiuse_api->api_version != WIIUSE_API_VERSION) { - wiiuse_shutdown(); - return NULL; - } - - /* set all the function pointers */ - wiiuse_init = wiiuse_api->_wiiuse_init; - wiiuse_disconnected = wiiuse_api->_wiiuse_disconnected; - wiiuse_rumble = wiiuse_api->_wiiuse_rumble; - wiiuse_toggle_rumble = wiiuse_api->_wiiuse_toggle_rumble; - wiiuse_set_leds = wiiuse_api->_wiiuse_set_leds; - wiiuse_motion_sensing = wiiuse_api->_wiiuse_motion_sensing; - wiiuse_read_data = wiiuse_api->_wiiuse_read_data; - wiiuse_write_data = wiiuse_api->_wiiuse_write_data; - wiiuse_status = wiiuse_api->_wiiuse_status; - wiiuse_get_by_id = wiiuse_api->_wiiuse_get_by_id; - wiiuse_set_flags = wiiuse_api->_wiiuse_set_flags; - wiiuse_set_smooth_alpha = wiiuse_api->_wiiuse_set_smooth_alpha; - wiiuse_set_ir = wiiuse_api->_wiiuse_set_ir; - wiiuse_set_ir_vres = wiiuse_api->_wiiuse_set_ir_vres; - wiiuse_set_ir_position = wiiuse_api->_wiiuse_set_ir_position; - wiiuse_set_aspect_ratio = wiiuse_api->_wiiuse_set_aspect_ratio; - wiiuse_set_bluetooth_stack = wiiuse_api->_wiiuse_set_bluetooth_stack; - wiiuse_set_orient_threshold = wiiuse_api->_wiiuse_set_orient_threshold; - wiiuse_find = wiiuse_api->_wiiuse_find; - wiiuse_connect = wiiuse_api->_wiiuse_connect; - wiiuse_disconnect = wiiuse_api->_wiiuse_disconnect; - wiiuse_poll = wiiuse_api->_wiiuse_poll; - - printf("wiiuse v%s loaded ( http://wiiuse.net http://wiiuse.sf.net/ ).\n", wiiuse_api->version); - - return wiiuse_api->version; -} - - -/** - * @brief Unload the library. - * - * @see wiiuse_startup() - */ -void wiiuse_shutdown() { - if (!wiiuse_mod) - return; - - /* unload the module */ - dlclose(wiiuse_mod); - - wiiuse_api = NULL; - - wiiuse_init = NULL; - wiiuse_disconnected = NULL; - wiiuse_rumble = NULL; - wiiuse_toggle_rumble = NULL; - wiiuse_set_leds = NULL; - wiiuse_motion_sensing = NULL; - wiiuse_read_data = NULL; - wiiuse_write_data = NULL; - wiiuse_status = NULL; - wiiuse_get_by_id = NULL; - wiiuse_set_flags = NULL; - wiiuse_set_smooth_alpha = NULL; - wiiuse_set_ir = NULL; - wiiuse_set_ir_vres = NULL; - wiiuse_set_ir_position = NULL; - wiiuse_set_aspect_ratio = NULL; - wiiuse_set_bluetooth_stack = NULL; - wiiuse_set_orient_threshold = NULL; - wiiuse_find = NULL; - wiiuse_connect = NULL; - wiiuse_disconnect = NULL; - wiiuse_poll = NULL; - -} diff --git a/tag1/WiiUseJC/wiiuse.h b/tag1/WiiUseJC/wiiuse.h deleted file mode 100644 index 9a466d9..0000000 --- a/tag1/WiiUseJC/wiiuse.h +++ /dev/null @@ -1,687 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -/* ignore this, this is used internally for wiiuse */ -#ifdef __WIIUSE__ - #ifndef WIIUSE_INTERNAL_H_INCLUDED - #error wiiuse.h included directly. Must include wiiuse_internal.h instead. - #endif - #define WCONST -#else - #define WCONST const -#endif - -#if defined(WIN32) || defined(__WIN32__) - /* windows */ - #include - #include - #include - #include - - #define dlopen(file, x) (void*)LoadLibrary(file) - #define dlsym(dll, func) (void*)GetProcAddress((HMODULE)(dll), (func)) - #define dlclose(dll) FreeLibrary((HMODULE)(dll)) - #define Dl_info MEMORY_BASIC_INFORMATION - #define dladdr(func, inf) VirtualQuery(func, inf, sizeof(*inf)) -#else - /* nix */ - #include -#endif - -/* wiiuse version and API version */ -#define WIIUSE_VERSION "0.9" -#define WIIUSE_API_VERSION 8 - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x10) == 0x10) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x20) == 0x20) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x40) == 0x40) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - -/** - * @brief Event callback. - * - * @param wm Pointer to a wiimote_t structure. - * @param btns What buttons are currently pressed. They are OR'ed together. - * @param accel Acceleration of the device along each axis. - * This is the raw data reported by the wiimote. - * @param orient Orientation (roll, pitch, yaw) of the device. - * @param gforce Pull of gravity on each axis of the device (measured in gravity units). - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when an event occurs on the specified wiimote. - */ -typedef void (*wiiuse_event_cb)(struct wiimote_t* wm); - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - -/** - * @brief Callback that handles a controller status event. - * - * @param wm Pointer to a wiimote_t structure. - * @param attachment Is there an attachment? (1 for yes, 0 for no) - * @param speaker Is the speaker enabled? (1 for yes, 0 for no) - * @param ir Is the IR support enabled? (1 for yes, 0 for no) - * @param led What LEDs are lit. - * @param battery_level Battery level, between 0.0 (0%) and 1.0 (100%). - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when either the controller status changed or the controller - * status was requested explicitly by wiiuse_status(). - */ -typedef void (*wiiuse_ctrl_status_cb)(struct wiimote_t* wm, int attachment, int speaker, int ir, int led[4], float battery_level); - -/** - * @brief Callback that handles a disconnection event. - * - * @param wm Pointer to a wiimote_t structure. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when a disconnection occurs. This can happen if the POWER button - * is pressed or if the connection is interrupted. - */ -typedef void (*wiiuse_dis_cb)(struct wiimote_t* wm); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; - float pitch; - float yaw; -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< gravity calibration */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - enum { - EXP_NONE, - EXP_NUNCHUK, - EXP_CLASSIC - } type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - byte exp_btns; - struct orient_t exp_orient; - float exp_r_shoulder; - float exp_l_shoulder; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; -} wiimote_state_t; - - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - #endif - - WCONST int state; /**< various state flags */ - WCONST int leds; /**< currently lit leds */ - - WCONST int flags; /**< options flag */ - - WCONST wiiuse_event_cb event_cb; /**< event callback */ - WCONST wiiuse_dis_cb dis_cb; /**< disconnect callback */ - WCONST wiiuse_ctrl_status_cb stat_cb; /**< controller status callback */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST byte event[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -typedef struct wiimote_t** (*_wiiuse_init_fptr)(int wiimotes, int* unids, wiiuse_event_cb event_cb, wiiuse_ctrl_status_cb stat_cb, wiiuse_dis_cb dis_cb); -typedef void (*_wiiuse_disconnected_fptr)(struct wiimote_t* wm); -typedef void (*_wiiuse_rumble_fptr)(struct wiimote_t* wm, int status); -typedef void (*_wiiuse_toggle_rumble_fptr)(struct wiimote_t* wm); -typedef void (*_wiiuse_set_leds_fptr)(struct wiimote_t* wm, int leds); -typedef void (*_wiiuse_motion_sensing_fptr)(struct wiimote_t* wm, int status); -typedef int (*_wiiuse_read_data_fptr)(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int offset, unsigned short len); -typedef int (*_wiiuse_write_data_fptr)(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -typedef void (*_wiiuse_status_fptr)(struct wiimote_t* wm); -typedef struct wiimote_t* (*_wiiuse_get_by_id_fptr)(struct wiimote_t** wm, int wiimotes, int unid); -typedef int (*_wiiuse_set_flags_fptr)(struct wiimote_t* wm, int enable, int disable); -typedef float (*_wiiuse_set_smooth_alpha_fptr)(struct wiimote_t* wm, float alpha); -typedef void (*_wiiuse_set_ir_fptr)(struct wiimote_t* wm, int status); -typedef void (*_wiiuse_set_ir_vres_fptr)(struct wiimote_t* wm, unsigned int x, unsigned int y); -typedef void (*_wiiuse_set_ir_position_fptr)(struct wiimote_t* wm, enum ir_position_t pos); -typedef void (*_wiiuse_set_aspect_ratio_fptr)(struct wiimote_t* wm, enum aspect_t aspect); -typedef void (*_wiiuse_set_bluetooth_stack_fptr)(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -typedef void (*_wiiuse_set_orient_threshold_fptr)(struct wiimote_t* wm, float threshold); - -/* connect.c */ -typedef int (*_wiiuse_find_fptr)(struct wiimote_t** wm, int max_wiimotes, int timeout); -typedef int (*_wiiuse_connect_fptr)(struct wiimote_t** wm, int wiimotes); -typedef void (*_wiiuse_disconnect_fptr)(struct wiimote_t* wm); - -/* events.c */ -typedef void (*_wiiuse_poll_fptr)(struct wiimote_t** wm, int wiimotes); - -#ifdef __cplusplus -} -#endif - -/** - * @struct wiiuse_api_t - * @brief API structure that is filled by the library - * when the entry point is invoked. - * - * Unless you are modifying wiiuse, you probably - * will not be interested in any members - * that begin with an underscore (_). - */ -struct wiiuse_api_t { - const char* version; /**< wiiuse version */ - int api_version; /**< wiiuse API version */ - - _wiiuse_init_fptr _wiiuse_init; - _wiiuse_disconnected_fptr _wiiuse_disconnected; - _wiiuse_rumble_fptr _wiiuse_rumble; - _wiiuse_toggle_rumble_fptr _wiiuse_toggle_rumble; - _wiiuse_set_leds_fptr _wiiuse_set_leds; - _wiiuse_motion_sensing_fptr _wiiuse_motion_sensing; - _wiiuse_read_data_fptr _wiiuse_read_data; - _wiiuse_write_data_fptr _wiiuse_write_data; - _wiiuse_status_fptr _wiiuse_status; - _wiiuse_get_by_id_fptr _wiiuse_get_by_id; - _wiiuse_set_flags_fptr _wiiuse_set_flags; - _wiiuse_set_smooth_alpha_fptr _wiiuse_set_smooth_alpha; - _wiiuse_set_ir_fptr _wiiuse_set_ir; - _wiiuse_set_ir_vres_fptr _wiiuse_set_ir_vres; - _wiiuse_set_ir_position_fptr _wiiuse_set_ir_position; - _wiiuse_set_aspect_ratio_fptr _wiiuse_set_aspect_ratio; - _wiiuse_set_bluetooth_stack_fptr _wiiuse_set_bluetooth_stack; - _wiiuse_set_orient_threshold_fptr _wiiuse_set_orient_threshold; - - _wiiuse_find_fptr _wiiuse_find; - _wiiuse_connect_fptr _wiiuse_connect; - _wiiuse_disconnect_fptr _wiiuse_disconnect; - - _wiiuse_poll_fptr _wiiuse_poll; -}; - -#ifndef __WIIUSE__ - -/* - * Operating system dependent macros. - */ -#ifdef __WIN32__ - #define dlopen(file, x) (void*)LoadLibrary(file) - #define dlsym(dll, func) (void*)GetProcAddress((HMODULE)(dll), (func)) - #define dlclose(dll) FreeLibrary((HMODULE)(dll)) - - char* _dlerror(); - #define dlerror() _dlerror() -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* api/wiiuse.c */ -const char* wiiuse_startup(char* wiiuse_file); -void wiiuse_shutdown(); - -#ifdef WIIUSE_API_SRC - #define WEXTERN -#else - #define WEXTERN extern -#endif - -WEXTERN _wiiuse_init_fptr wiiuse_init; -WEXTERN _wiiuse_disconnected_fptr wiiuse_disconnected; -WEXTERN _wiiuse_rumble_fptr wiiuse_rumble; -WEXTERN _wiiuse_toggle_rumble_fptr wiiuse_toggle_rumble; -WEXTERN _wiiuse_set_leds_fptr wiiuse_set_leds; -WEXTERN _wiiuse_motion_sensing_fptr wiiuse_motion_sensing; -WEXTERN _wiiuse_read_data_fptr wiiuse_read_data; -WEXTERN _wiiuse_write_data_fptr wiiuse_write_data; -WEXTERN _wiiuse_status_fptr wiiuse_status; -WEXTERN _wiiuse_get_by_id_fptr wiiuse_get_by_id; -WEXTERN _wiiuse_set_flags_fptr wiiuse_set_flags; -WEXTERN _wiiuse_set_smooth_alpha_fptr wiiuse_set_smooth_alpha; -WEXTERN _wiiuse_set_ir_fptr wiiuse_set_ir; -WEXTERN _wiiuse_set_ir_vres_fptr wiiuse_set_ir_vres; -WEXTERN _wiiuse_set_ir_position_fptr wiiuse_set_ir_position; -WEXTERN _wiiuse_set_aspect_ratio_fptr wiiuse_set_aspect_ratio; -WEXTERN _wiiuse_set_bluetooth_stack_fptr wiiuse_set_bluetooth_stack; -WEXTERN _wiiuse_set_orient_threshold_fptr wiiuse_set_orient_threshold; - -WEXTERN _wiiuse_find_fptr wiiuse_find; -WEXTERN _wiiuse_connect_fptr wiiuse_connect; -WEXTERN _wiiuse_disconnect_fptr wiiuse_disconnect; - -WEXTERN _wiiuse_poll_fptr wiiuse_poll; - -#ifdef __cplusplus -} -#endif - -#endif /* __WIIUSE__ */ - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/tag1/WiiUseJC/wiiusej_WiiUseApi.c b/tag1/WiiUseJC/wiiusej_WiiUseApi.c deleted file mode 100644 index ddcd75e..0000000 --- a/tag1/WiiUseJC/wiiusej_WiiUseApi.c +++ /dev/null @@ -1,462 +0,0 @@ -#ifndef WIN32 -#include -#define WIIUSE_PATH "./wiiuse.so" -#else -#define WIIUSE_PATH "wiiuse.dll" -#endif - -#include "wiiusej_WiiUseApi.h" -#include "wiiuse.h" -/* - * These are some identifiers for wiimotes - * - * See below in main() for what they are used for. - */ -#define WIIMOTE_ID_1 0 -#define WIIMOTE_ID_2 1 -#define WIIMOTE_STATE_RUMBLE 0x08 -#define WIIMOTE_STATE_CONNECTED 0x04 -#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) -#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) - -/****************** CALLBACKS DECLARATIONS *************************/ - -static void handle_event(struct wiimote_t* wm); -static void handle_ctrl_status(struct wiimote_t* wm, int attachment, - int speaker, int ir, int led[4], float battery_level); -static void handle_disconnect(wiimote* wm); - -static void copy_common_status(struct wiimote_t* wm);/* function with common code for callbacks */ - -/********************* VARIABLES DECLARATIONS *****************************/ - -/* - * Make a temp array of wiimote ids. - * Here I only anticipate connecting up to - * two wiimotes. Each wiimote connected - * will get one of these ids. - */ -static int ids[] = { WIIMOTE_ID_1, WIIMOTE_ID_2 }; -static wiimote** wiimotes; -static JNIEnv *globalEnv; -static jobject globalObj; -static jobject globalWim; - -/****************** GENERAL FUNCTIONS DEFINITIONS *************************/ - -/* - * Load the wiiuse library - * - * This needs to be done before anything else can happen - * wiiuse_startup() will return the version of the library loaded. - * - * @return 0 if there is an error, 1 if everything is ok. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_loadLibrary -(JNIEnv *env, jobject obj) { - const char* version; - version = wiiuse_startup(WIIUSE_PATH); - //printf("Wiiuse Version = %s\n", version); - if (!version) { - return 0; - } - - /* no problems loading library */ - return 1; -} - -/** - * Try to connect to 2 wiimotes. - * Make them rumble to show they are connected. - * - * @return 0 if there is an error otherwise it returns - * the number of wiimotes connected.. - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections -(JNIEnv *env, jobject obj) { - - /* variables declarations */ - int found, connected; - - /* - * Initialize an array of wiimote objects. - * - * The first parameter is the number of wiimotes - * I want to create. I only have two wiimotes - * so I'm limiting the test to just 2. - * - * Then I get it the array of ids and a couple - * callback functions to invoke when something - * happens on one of the wiimotes. - * - * handle_event gets called when a generic event occurs (button press, motion sensing, etc) - * handle_ctrl_status gets called when a response to a status request arrives (battery power, etc) - * handle_disconnect gets called when the wiimote disconnect (holding power button) - */ - wiimotes = wiiuse_init(2, ids, handle_event, handle_ctrl_status, - handle_disconnect); - - /* - * Find wiimote devices - * Now we need to find some wiimotes. - * Give the function the wiimote array we created, and tell it there - * are 2 wiimotes we are interested in. - * Set the timeout to be 5 seconds. - * This will return the number of actual wiimotes that are in discovery mode. - */ - found = wiiuse_find(wiimotes, 2, 5); - if (!found) return 0; - - /* - * Connect to the wiimotes - * Now that we found some wiimotes, connect to them. - * Give the function the wiimote array and the number of wiimote devices we found. - * This will return the number of established connections to the found wiimotes. - */ - connected = wiiuse_connect(wiimotes, 2); - if (!connected) return 0; - - //no problems during connection show that wiimotes are connected - - /* - * Now set the LEDs and rumble for a second so it's easy - * to tell which wiimotes are connected (just like the wii does). - */ - wiiuse_set_leds(wiimotes[0], WIIMOTE_LED_1); - wiiuse_set_leds(wiimotes[1], WIIMOTE_LED_2); - wiiuse_rumble(wiimotes[0], 1); - wiiuse_rumble(wiimotes[1], 1); - -#ifndef WIN32 - usleep(200000); -#else - Sleep(200); -#endif - - wiiuse_rumble(wiimotes[0], 0); - wiiuse_rumble(wiimotes[1], 0); - - //no pb connecting leave - return connected; -} - -/** - * Close connection to the wiimote with the given id. - * - * @param id the id of the wiimote to disconnect.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection -(JNIEnv *env, jobject obj, jint id) { - wiiuse_disconnect(wiimotes[id]); -} - -/** - * Shutdown api. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi -(JNIEnv *env, jobject obj) { - wiiuse_shutdown(); -} - -/** - * Activate rumble for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble -(JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiimotes[id], 1); -} - -/** - * Deactivate rumble for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble -(JNIEnv *env, jobject obj, jint id) { - wiiuse_rumble(wiimotes[id], 0); -} - -/** - * Activate IR TRacking for the wiimote with the given id. - * @param id the id of the wiimote. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiimotes[id], 1); -} - -/** - * Deactivate IR TRacking for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_ir(wiimotes[id], 0); -} - -/** - * Activate Motion Sensing for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiimotes[id], 1); -} - -/** - * Deactivate Motion Sensing for the wiimote with the given id. - * @param id the id of the wiimote.Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_motion_sensing(wiimotes[id], 0); -} - -/** - * Set wiimote leds status. - * @param id the id of the wiimote concerned - * @param led1 status of led1: True=ON, False=OFF - * @param led2 status of led2: True=ON, False=OFF - * @param led3 status of led3: True=ON, False=OFF - * @param led4 status of led4: True=ON, False=OFF - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds -(JNIEnv *env, jobject obj, jint id, jboolean led1, jboolean led2, jboolean led3, jboolean led4) { - int leds = 0; - - if (led1) leds |= WIIMOTE_LED_1; - if (led2) leds |= WIIMOTE_LED_2; - if (led3) leds |= WIIMOTE_LED_3; - if (led4) leds |= WIIMOTE_LED_4; - - wiiuse_set_leds(wiimotes[id], leds); -} - -/** - * 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 - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold -(JNIEnv *env, jobject obj, jint id, jfloat thresh) { - wiiuse_set_orient_threshold(wiimotes[id], thresh); -} - -/** - * Make the the accelerometers give smoother results. - * This is set by default. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiimotes[id], WIIUSE_SMOOTHING, 0); -} - -/** - * Make the the accelerometers give raw results. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiimotes[id], 0, WIIUSE_SMOOTHING); -} - -/** - * Make the wiimote generate an event each time we poll. - * Not set by default. - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiimotes[id], WIIUSE_CONTINUOUS, 0); -} - -/** - * Make the wiimote generate an event only when there is one. - * (default behavior) - * @param id the id of the wiimote concerned - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous -(JNIEnv *env, jobject obj, jint id) { - wiiuse_set_flags(wiimotes[id], 0, WIIUSE_CONTINUOUS); -} - -/** - * Get status from the wiimotes and send it through call backs. - * - * @param id the id of the wiimote. Must be 1 or 2. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus -(JNIEnv *env, jobject obj, jint id) { - wiiuse_status(wiimotes[id]); -} - -/** - * Get status and values from the wiimotes and send it through callbacks. - * @param wim the wiimote object to fill with the datas. - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll -(JNIEnv *env, jobject obj, jobject wim) { - - globalEnv = env; - globalObj = obj; - globalWim = wim; - - wiiuse_poll(wiimotes, 2); -} - -/****************** CALLBACKS DEFINITIONS *************************/ - -/** - * @brief Callback that handles an event. - * - * @param wm Pointer to a wiimote_t structure. - * - * This function is called automatically by the wiiuse library when an - * event occurs on the specified wiimote. - */ -static void handle_event(struct wiimote_t* wm) { - - /* Variables Declarations */ - jclass cls = (*globalEnv)->GetObjectClass(globalEnv, globalWim); - jmethodID mid; - - /* fill java class */ - copy_common_status(wm); - - /* Set all buttons */ - mid = (*globalEnv)->GetMethodID(globalEnv, cls, "setAllButtons", "(SSS)V"); - if (mid == 0) { - return; - } - (*globalEnv)->CallVoidMethod(globalEnv, globalWim, mid, wm->btns, - wm->btns_released, wm->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(wm)) { - int i = 0; - /* go through each of the 4 possible IR sources */ - for (; i < 4; ++i) { - /* check if the source is visible */ - if (wm->ir.dot[i].visible) { - cls = (*globalEnv)->GetObjectClass(globalEnv, globalWim); - mid = (*globalEnv)->GetMethodID(globalEnv, cls, "addIRpoint", - "(II)V"); - if (mid == 0) { - return; - } - (*globalEnv)->CallVoidMethod(globalEnv, globalWim, mid, - wm->ir.dot[i].x, wm->ir.dot[i].y); - } - } - //printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y); - //printf("IR z distance: %f\n", wm->ir.z); - } - - /* Motion Sensing */ - if (WIIUSE_USING_ACC(wm)) { - /* set orientation and gravity force */ - cls = (*globalEnv)->GetObjectClass(globalEnv, globalWim); - mid = (*globalEnv)->GetMethodID(globalEnv, cls, - "setOrientationAndGforce", "(FFFFFF)V"); - if (mid == 0) { - return; - } - (*globalEnv)->CallVoidMethod(globalEnv, globalWim, mid, - wm->orient.roll, wm->orient.pitch, wm->orient.yaw, - wm->gforce.x, wm->gforce.y, wm->gforce.z); - } -} - -/** - * @brief Callback that handles a controller status event. - * - * @param wm Pointer to a wiimote_t structure. - * @param attachment Is there an attachment? (1 for yes, 0 for no) - * @param speaker Is the speaker enabled? (1 for yes, 0 for no) - * @param ir Is the IR support enabled? (1 for yes, 0 for no) - * @param led What LEDs are lit. - * @param battery_level Battery level, between 0.0 (0%) and 1.0 (100%). - * - * This occurs when either the controller status changed - * or the controller status was requested explicitly by - * wiiuse_status(). - * - * One reason the status can change is if the nunchuk was - * inserted or removed from the expansion port. - */ -static void handle_ctrl_status(struct wiimote_t* wm, int attachment, - int speaker, int ir, int led[4], float battery_level) { - - /* Variables Declarations */ - jclass cls = (*globalEnv)->GetObjectClass(globalEnv, globalWim); - jmethodID mid; - short leds = 0; - - /* fill java class */ - copy_common_status(wm); - - /* LEDS */ - if (led[0]) - leds += 1; - if (led[1]) - leds += 2; - if (led[2]) - leds += 4; - if (led[3]) - leds += 8; - - /* set values for battery, leds, speaker and attachment*/ - mid = (*globalEnv)->GetMethodID(globalEnv, cls, - "setBatteryLedsSpeakerAttachment", "(FSZZ)V"); - if (mid == 0) { - return; - } - (*globalEnv)->CallVoidMethod(globalEnv, globalWim, mid, - battery_level, leds, speaker, attachment); - -} - -/** - * @brief Callback that handles a disconnection event. - * - * @param wm Pointer to a wiimote_t structure. - * - * This can happen if the POWER button is pressed, or - * if the connection is interrupted. - */ -static void handle_disconnect(wiimote* wm) { - - /* call java method handling disconnection */ - copy_common_status(wm); -} - -/** - * Fills status variables. This method fills some status variables always filled in a WiiMoteEvent object. - * This function is called in every callback function. - */ -static void copy_common_status(struct wiimote_t* wm) { - - /* Variables Declarations */ - jmethodID mid; - jclass cls = (*globalEnv)->GetObjectClass(globalEnv, globalWim); - - /* set statuses */ - mid = (*globalEnv)->GetMethodID(globalEnv, cls, "setPermanentStatus", - "(IZZZZFZZ)V"); - if (mid == 0) { - return; - } - (*globalEnv)->CallVoidMethod(globalEnv, globalWim, mid, - wm->unid, WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED), - WIIUSE_USING_IR(wm), WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE), - WIIUSE_USING_ACC(wm), wm->orient_threshold, - WIIMOTE_IS_FLAG_SET(wm,WIIUSE_CONTINUOUS), - WIIMOTE_IS_FLAG_SET(wm,WIIUSE_SMOOTHING)); - -} diff --git a/tag1/WiiUseJC/wiiusej_WiiUseApi.def b/tag1/WiiUseJC/wiiusej_WiiUseApi.def deleted file mode 100644 index 258bf8b..0000000 --- a/tag1/WiiUseJC/wiiusej_WiiUseApi.def +++ /dev/null @@ -1,19 +0,0 @@ -EXPORTS -Java_wiiusej_WiiUseApi_loadLibrary -Java_wiiusej_WiiUseApi_doConnections -Java_wiiusej_WiiUseApi_closeConnection -Java_wiiusej_WiiUseApi_shutdownApi -Java_wiiusej_WiiUseApi_activateRumble -Java_wiiusej_WiiUseApi_deactivateRumble -Java_wiiusej_WiiUseApi_activateIRTracking -Java_wiiusej_WiiUseApi_deactivateIRTracking -Java_wiiusej_WiiUseApi_activateMotionSensing -Java_wiiusej_WiiUseApi_setOrientThreshold -Java_wiiusej_WiiUseApi_activateSmoothing -Java_wiiusej_WiiUseApi_setLeds -Java_wiiusej_WiiUseApi_deactivateSmoothing -Java_wiiusej_WiiUseApi_activateContinuous -Java_wiiusej_WiiUseApi_deactivateContinuous -Java_wiiusej_WiiUseApi_deactivateMotionSensing -Java_wiiusej_WiiUseApi_getStatus -Java_wiiusej_WiiUseApi_specialPoll diff --git a/tag1/WiiUseJC/wiiusej_WiiUseApi.h b/tag1/WiiUseJC/wiiusej_WiiUseApi.h deleted file mode 100644 index 08efaf1..0000000 --- a/tag1/WiiUseJC/wiiusej_WiiUseApi.h +++ /dev/null @@ -1,157 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class wiiusej_WiiUseApi */ - -#ifndef _Included_wiiusej_WiiUseApi -#define _Included_wiiusej_WiiUseApi -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: wiiusej_WiiUseApi - * Method: loadLibrary - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_loadLibrary - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: doConnections - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_wiiusej_WiiUseApi_doConnections - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: closeConnection - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_closeConnection - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: shutdownApi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi - (JNIEnv *, jobject); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateRumble - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateRumble - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateIRTracking - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateIRTracking - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateMotionSensing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateMotionSensing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: setLeds - * Signature: (IZZZZ)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setLeds - (JNIEnv *, jobject, jint, jboolean, jboolean, jboolean, jboolean); - -/* - * Class: wiiusej_WiiUseApi - * Method: setOrientThreshold - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setOrientThreshold - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateSmoothing - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSmoothing - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: activateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: deactivateContinuous - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateContinuous - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: getStatus - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_getStatus - (JNIEnv *, jobject, jint); - -/* - * Class: wiiusej_WiiUseApi - * Method: specialPoll - * Signature: (Lwiiusej/WiiMoteEvent;)V - */ -JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll - (JNIEnv *, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif