From a8fd183b79f7f505eec9c99ca63ff36b586122f2 Mon Sep 17 00:00:00 2001 From: "guilhem.duche" Date: Thu, 8 May 2008 00:10:20 +0000 Subject: [PATCH] 0.12 work in progress git-svn-id: http://wiiusej.googlecode.com/svn/trunk@138 ae48ae66-6a45-0410-b38e-211266189506 --- WiiUseJ/.settings/org.eclipse.jdt.ui.prefs | 3 + .../physicalevents/ExpansionEvent.java | 39 +++++ .../physicalevents/JoystickEvent.java | 136 ++++++++++++++++++ .../physicalevents/NunchukEvent.java | 58 ++++++++ 4 files changed, 236 insertions(+) create mode 100644 WiiUseJ/.settings/org.eclipse.jdt.ui.prefs create mode 100644 WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java create mode 100644 WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java create mode 100644 WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java diff --git a/WiiUseJ/.settings/org.eclipse.jdt.ui.prefs b/WiiUseJ/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..81f7b8f --- /dev/null +++ b/WiiUseJ/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +#Thu May 08 01:25:43 CEST 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java new file mode 100644 index 0000000..bcd4425 --- /dev/null +++ b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/ExpansionEvent.java @@ -0,0 +1,39 @@ +/** + * 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. + * @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/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java new file mode 100644 index 0000000..1c5a3bf --- /dev/null +++ b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/JoystickEvent.java @@ -0,0 +1,136 @@ +/** + * 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, int angle, int 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 += "--- Active : true\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/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java new file mode 100644 index 0000000..6e80cd9 --- /dev/null +++ b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukEvent.java @@ -0,0 +1,58 @@ +/** + * 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; + + /** + * @param id + */ + public NunchukEvent(int id) { + super(id); + // TODO Auto-generated constructor stub + } + + + + + /* + * (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; + } + +}