updates classic controller
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@186 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package wiiusej.test;
|
package wiiusej.test;
|
||||||
|
|
||||||
|
import wiiusej.WiiUseApiManager;
|
||||||
import wiiusej.Wiimote;
|
import wiiusej.Wiimote;
|
||||||
import wiiusej.utils.ClassicControllerButtonsEventPanel;
|
import wiiusej.utils.ClassicControllerButtonsEventPanel;
|
||||||
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
|
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
|
||||||
@@ -75,33 +76,37 @@ public class ClassicControllerGuiTest extends javax.swing.JFrame implements Wiim
|
|||||||
rightShoulderBar = new javax.swing.JProgressBar();
|
rightShoulderBar = new javax.swing.JProgressBar();
|
||||||
classicControllerPanel = new wiiusej.utils.ClassicControllerButtonsEventPanel();
|
classicControllerPanel = new wiiusej.utils.ClassicControllerButtonsEventPanel();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
setTitle("WiiuseJ Classic Controller Test GUI");
|
setTitle("WiiuseJ Classic Controller Test GUI");
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
shouldersPanel.setMaximumSize(new java.awt.Dimension(350, 16));
|
||||||
|
shouldersPanel.setMinimumSize(new java.awt.Dimension(350, 16));
|
||||||
|
shouldersPanel.setPreferredSize(new java.awt.Dimension(350, 16));
|
||||||
shouldersPanel.setLayout(new javax.swing.BoxLayout(shouldersPanel, javax.swing.BoxLayout.LINE_AXIS));
|
shouldersPanel.setLayout(new javax.swing.BoxLayout(shouldersPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
shouldersPanel.add(leftShoulderBar);
|
shouldersPanel.add(leftShoulderBar);
|
||||||
shouldersPanel.add(rightShoulderBar);
|
shouldersPanel.add(rightShoulderBar);
|
||||||
|
|
||||||
getContentPane().add(shouldersPanel);
|
getContentPane().add(shouldersPanel);
|
||||||
|
|
||||||
|
classicControllerPanel.setMaximumSize(new java.awt.Dimension(350, 182));
|
||||||
|
classicControllerPanel.setMinimumSize(new java.awt.Dimension(350, 182));
|
||||||
|
|
||||||
javax.swing.GroupLayout classicControllerPanelLayout = new javax.swing.GroupLayout(classicControllerPanel);
|
javax.swing.GroupLayout classicControllerPanelLayout = new javax.swing.GroupLayout(classicControllerPanel);
|
||||||
classicControllerPanel.setLayout(classicControllerPanelLayout);
|
classicControllerPanel.setLayout(classicControllerPanelLayout);
|
||||||
classicControllerPanelLayout.setHorizontalGroup(
|
classicControllerPanelLayout.setHorizontalGroup(
|
||||||
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 400, Short.MAX_VALUE)
|
.addGap(0, 350, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
classicControllerPanelLayout.setVerticalGroup(
|
classicControllerPanelLayout.setVerticalGroup(
|
||||||
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 284, Short.MAX_VALUE)
|
.addGap(0, 182, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
getContentPane().add(classicControllerPanel);
|
getContentPane().add(classicControllerPanel);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,6 @@ public class ClassicControllerGuiTest extends javax.swing.JFrame implements Wiim
|
|||||||
leftShoulderBar.setValue(Math.round(leftShoulder * MAX_SHOULDER));
|
leftShoulderBar.setValue(Math.round(leftShoulder * MAX_SHOULDER));
|
||||||
rightShoulderBar.setValue(Math.round(rightShoulder * MAX_SHOULDER));
|
rightShoulderBar.setValue(Math.round(rightShoulder * MAX_SHOULDER));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStatusEvent(StatusEvent arg0) {
|
public void onStatusEvent(StatusEvent arg0) {
|
||||||
@@ -156,6 +160,16 @@ public class ClassicControllerGuiTest extends javax.swing.JFrame implements Wiim
|
|||||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||||
|
// ClassicControllerGuiTest gui = null;
|
||||||
|
// if (wiimotes.length > 0) {
|
||||||
|
// gui = new ClassicControllerGuiTest(wiimotes[0]);
|
||||||
|
// }
|
||||||
|
// gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
|
||||||
|
// gui.setVisible(true);
|
||||||
|
// }
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JPanel classicControllerPanel;
|
private javax.swing.JPanel classicControllerPanel;
|
||||||
private javax.swing.JProgressBar leftShoulderBar;
|
private javax.swing.JProgressBar leftShoulderBar;
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
package wiiusej.test;
|
package wiiusej.test;
|
||||||
|
|
||||||
import wiiusej.Wiimote;
|
import wiiusej.Wiimote;
|
||||||
import wiiusej.utils.GuitarHero3ButtonsEventPanel;
|
|
||||||
import wiiusej.utils.GuitarHeroJoystickEventPanel;
|
|
||||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||||
import wiiusej.wiiusejevents.physicalevents.GuitarHeroButtonsEvent;
|
|
||||||
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||||
@@ -69,7 +66,6 @@ public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteLis
|
|||||||
guitarHero3JoystickPanel = new wiiusej.utils.GuitarHeroJoystickEventPanel();
|
guitarHero3JoystickPanel = new wiiusej.utils.GuitarHeroJoystickEventPanel();
|
||||||
whammyProgressBar = new javax.swing.JProgressBar();
|
whammyProgressBar = new javax.swing.JProgressBar();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
setTitle("WiiuseJ Guitar Hero 3 Test GUI");
|
setTitle("WiiuseJ Guitar Hero 3 Test GUI");
|
||||||
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
@@ -79,7 +75,7 @@ public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteLis
|
|||||||
buttonsEventPanel.setLayout(buttonsEventPanelLayout);
|
buttonsEventPanel.setLayout(buttonsEventPanelLayout);
|
||||||
buttonsEventPanelLayout.setHorizontalGroup(
|
buttonsEventPanelLayout.setHorizontalGroup(
|
||||||
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 448, Short.MAX_VALUE)
|
.addGap(0, 526, Short.MAX_VALUE)
|
||||||
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
@@ -88,7 +84,7 @@ public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteLis
|
|||||||
);
|
);
|
||||||
buttonsEventPanelLayout.setVerticalGroup(
|
buttonsEventPanelLayout.setVerticalGroup(
|
||||||
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 111, Short.MAX_VALUE)
|
.addGap(0, 96, Short.MAX_VALUE)
|
||||||
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
expansionFrame.addWindowListener(buttonSetter);
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
isFirstStatusGot = true;
|
isFirstStatusGot = true;
|
||||||
}
|
}
|
||||||
else if(arg0.isClassicControllerConnected()){
|
else if(arg0.isGuitarHeroConnected()){
|
||||||
showExpansionWiimoteButton.setEnabled(true);
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller");
|
showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller");
|
||||||
expansionFrame = new GuitarHero3GuiTest(wiimote);
|
expansionFrame = new GuitarHero3GuiTest(wiimote);
|
||||||
@@ -344,7 +344,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
|
|
||||||
public void onClassicControllerInsertedEvent(
|
public void onClassicControllerInsertedEvent(
|
||||||
ClassicControllerInsertedEvent arg0) {
|
ClassicControllerInsertedEvent arg0) {
|
||||||
messageText.setText("Nunchuk connected !");
|
messageText.setText("Classic controller connected !");
|
||||||
expansionText.setText("Expansion connected : Classic Controller.");
|
expansionText.setText("Expansion connected : Classic Controller.");
|
||||||
showExpansionWiimoteButton.setEnabled(true);
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
showExpansionWiimoteButton.setText("Show Classic Controller");
|
showExpansionWiimoteButton.setText("Show Classic Controller");
|
||||||
|
|||||||
@@ -57,8 +57,10 @@ public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel imple
|
|||||||
private Color releasedColor = Color.YELLOW;
|
private Color releasedColor = Color.YELLOW;
|
||||||
private Color joystickColor = Color.PINK;
|
private Color joystickColor = Color.PINK;
|
||||||
private Color shoulderColor = Color.BLUE;
|
private Color shoulderColor = Color.BLUE;
|
||||||
private Shape shapeJoystick = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
private Shape shapeJoystick = new java.awt.geom.Ellipse2D.Double(0, 0, 15, 15);
|
||||||
private Shape shapeButton = new java.awt.geom.Ellipse2D.Double(0, 0, 20, 20);
|
private Shape shapeButton = new java.awt.geom.Ellipse2D.Double(0, 0, 20, 20);
|
||||||
|
private static int xAmplitude = 20;
|
||||||
|
private static int yAmplitude = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Red : button just pressed. Orange : button held.
|
* Default constructor. Red : button just pressed. Orange : button held.
|
||||||
@@ -144,24 +146,24 @@ public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel imple
|
|||||||
|
|
||||||
/* button A */
|
/* button A */
|
||||||
if (buttons.isButtonAJustPressed()) {
|
if (buttons.isButtonAJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 304, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonAHeld()) {
|
if (buttons.isButtonAHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 304, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonAJustReleased()) {
|
if (buttons.isButtonAJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 304, 76, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button B */
|
/* button B */
|
||||||
if (buttons.isButtonBJustPressed()) {
|
if (buttons.isButtonBJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 269, 98, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonBHeld()) {
|
if (buttons.isButtonBHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 269, 98, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonBJustReleased()) {
|
if (buttons.isButtonBJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 269, 98, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Down */
|
/* button Down */
|
||||||
@@ -177,188 +179,169 @@ public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel imple
|
|||||||
|
|
||||||
/* button FullLeft */
|
/* button FullLeft */
|
||||||
if (buttons.isButtonFullLeftJustPressed()) {
|
if (buttons.isButtonFullLeftJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 55, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonFullLeftHeld()) {
|
if (buttons.isButtonFullLeftHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 55, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonFullLeftJustReleased()) {
|
if (buttons.isButtonFullLeftJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 55, 4, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button FullRight */
|
/* button FullRight */
|
||||||
if (buttons.isButtonFullRightJustPressed()) {
|
if (buttons.isButtonFullRightJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 276, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonFullRightHeld()) {
|
if (buttons.isButtonFullRightHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 276, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonFullRightJustReleased()) {
|
if (buttons.isButtonFullRightJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 276, 4, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Home */
|
/* button Home */
|
||||||
if (buttons.isButtonHomeJustPressed()) {
|
if (buttons.isButtonHomeJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 166, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonHomeHeld()) {
|
if (buttons.isButtonHomeHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 166, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonHomeJustReleased()) {
|
if (buttons.isButtonHomeJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 166, 76, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Left */
|
/* button Left */
|
||||||
if (buttons.isButtonLeftJustPressed()) {
|
if (buttons.isButtonLeftJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 34, 75, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonLeftHeld()) {
|
if (buttons.isButtonLeftHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 34, 75, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonLeftJustReleased()) {
|
if (buttons.isButtonLeftJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 34, 75, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Minus */
|
/* button Minus */
|
||||||
if (buttons.isButtonMinusJustPressed()) {
|
if (buttons.isButtonMinusJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 140, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonMinusHeld()) {
|
if (buttons.isButtonMinusHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 140, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonMinusJustReleased()) {
|
if (buttons.isButtonMinusJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 140, 76, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Plus */
|
/* button Plus */
|
||||||
if (buttons.isButtonPlusJustPressed()) {
|
if (buttons.isButtonPlusJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 191, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonPlusHeld()) {
|
if (buttons.isButtonPlusHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 191, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonPlusJustReleased()) {
|
if (buttons.isButtonPlusJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 191, 76, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Right */
|
/* button Right */
|
||||||
if (buttons.isButtonRightJustPressed()) {
|
if (buttons.isButtonRightJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 86, 75, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonRightHeld()) {
|
if (buttons.isButtonRightHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 86, 75, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonRightJustReleased()) {
|
if (buttons.isButtonRightJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 86, 353, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Up */
|
/* button Up */
|
||||||
if (buttons.isButtonUpJustPressed()) {
|
if (buttons.isButtonUpJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 59, 50, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonUpHeld()) {
|
if (buttons.isButtonUpHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 59, 50, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonUpJustReleased()) {
|
if (buttons.isButtonUpJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 59, 50, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button X */
|
/* button X */
|
||||||
if (buttons.isButtonXJustPressed()) {
|
if (buttons.isButtonXJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 271, 53, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonXHeld()) {
|
if (buttons.isButtonXHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 271, 53, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonXJustReleased()) {
|
if (buttons.isButtonXJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 271, 53, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button Y */
|
/* button Y */
|
||||||
if (buttons.isButtonYJustPressed()) {
|
if (buttons.isButtonYJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 237, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonYHeld()) {
|
if (buttons.isButtonYHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 237, 76, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonYJustReleased()) {
|
if (buttons.isButtonYJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 237, 76, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button ZL */
|
/* button ZL */
|
||||||
if (buttons.isButtonZLJustPressed()) {
|
if (buttons.isButtonZLJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 123, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonZLHeld()) {
|
if (buttons.isButtonZLHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 123, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonZLJustReleased()) {
|
if (buttons.isButtonZLJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 123, 4, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button ZR */
|
/* button ZR */
|
||||||
if (buttons.isButtonZRJustPressed()) {
|
if (buttons.isButtonZRJustPressed()) {
|
||||||
drawFunction(g2, pressedColor, 53, 353, shapeButton);
|
drawFunction(g2, pressedColor, 208, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonZRHeld()) {
|
if (buttons.isButtonZRHeld()) {
|
||||||
drawFunction(g2, heldColor, 53, 353, shapeButton);
|
drawFunction(g2, heldColor, 208, 4, shapeButton);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonZRJustReleased()) {
|
if (buttons.isButtonZRJustReleased()) {
|
||||||
drawFunction(g2, releasedColor, 53, 353, shapeButton);
|
drawFunction(g2, releasedColor, 208, 4, shapeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//joysticks
|
||||||
|
int halfWidth = (int) Math.round(shapeJoystick.getBounds().getWidth() / 2);
|
||||||
|
int halfHeight = (int) Math.round(shapeJoystick.getBounds().getHeight() / 2);
|
||||||
|
|
||||||
// left joystick
|
// left joystick
|
||||||
JoystickEvent jl = event.getClassicControllerLeftJoystickEvent();
|
JoystickEvent jl = event.getClassicControllerLeftJoystickEvent();
|
||||||
int xCenter1 = 50;
|
int xCenter1 = 121;
|
||||||
int yCenter1 = 50;
|
int yCenter1 = 125;
|
||||||
|
|
||||||
double xAng1 = Math.sin(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
double xAng1 = Math.sin(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
||||||
double yAng1 = Math.cos(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
double yAng1 = Math.cos(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
||||||
int dx1 = (int) Math.round(shapeJoystick.getBounds().getWidth() / 2);
|
|
||||||
int dy1 = (int) Math.round(shapeJoystick.getBounds().getHeight() / 2);
|
int xShift1 = (int) Math.round(xAng1 * xAmplitude);
|
||||||
double xTemp1 = xAng1 * (xCenter1 - dx1 * 2);
|
int yShift1 = (int) Math.round(yAng1 * yAmplitude);
|
||||||
double yTemp1 = yAng1 * (yCenter1 - dy1 * 2);
|
int x1 = xCenter1 + xShift1 - halfWidth;
|
||||||
int x1 = xCenter1 - dx1 + (int) xTemp1;
|
int y1 = yCenter1 - yShift1 - halfHeight;
|
||||||
int y1 = yCenter1 - dy1 - (int) yTemp1;
|
// draw shape
|
||||||
// shape
|
drawFunction(g2, joystickColor, x1, y1, shapeJoystick);
|
||||||
g2.translate(x1, y1);
|
|
||||||
g2.setPaint(joystickColor);
|
|
||||||
g2.draw(shapeJoystick);
|
|
||||||
g2.setPaint(joystickColor);
|
|
||||||
g2.fill(shapeJoystick);
|
|
||||||
g2.setTransform(new AffineTransform());
|
|
||||||
|
|
||||||
//Right joystick
|
//Right joystick
|
||||||
JoystickEvent jr = event.getClassicControllerRightJoystickEvent();
|
JoystickEvent jr = event.getClassicControllerRightJoystickEvent();
|
||||||
int xCenter2 = 50;
|
int xCenter2 = 213;
|
||||||
int yCenter2 = 50;
|
int yCenter2 = 125;
|
||||||
|
|
||||||
double xAng2 = Math.sin(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
double xAng2 = Math.sin(jr.getAngle() * Math.PI / 180.0) * jr.getMagnitude();
|
||||||
double yAng2 = Math.cos(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
|
double yAng2 = Math.cos(jr.getAngle() * Math.PI / 180.0) * jr.getMagnitude();
|
||||||
int dx2 = (int) Math.round(shapeJoystick.getBounds().getWidth() / 2);
|
|
||||||
int dy2 = (int) Math.round(shapeJoystick.getBounds().getHeight() / 2);
|
|
||||||
double xTemp2 = xAng2 * (xCenter2 - dx2 * 2);
|
|
||||||
double yTemp2 = yAng2 * (yCenter2 - dy2 * 2);
|
|
||||||
int x2 = xCenter2 - dx2 + (int) xTemp2;
|
|
||||||
int y2 = yCenter2 - dy2 - (int) yTemp2;
|
|
||||||
// shape
|
|
||||||
g2.translate(x2, y2);
|
|
||||||
g2.setPaint(joystickColor);
|
|
||||||
g2.draw(shapeJoystick);
|
|
||||||
g2.setPaint(joystickColor);
|
|
||||||
g2.fill(shapeJoystick);
|
|
||||||
g2.setTransform(new AffineTransform());
|
|
||||||
|
|
||||||
// draw shoulders
|
int xShift2 = (int) Math.round(xAng2 * xAmplitude);
|
||||||
float leftShoulder = event.getLeftShoulder();
|
int yShift2 = (int) Math.round(yAng2 * yAmplitude);
|
||||||
g2.setPaint(shoulderColor);
|
int x2 = xCenter2 + xShift2 - halfWidth;
|
||||||
g2.drawRect(10, 10, 10 + Math.round(leftShoulder * 70), 10 + 20);
|
int y2 = yCenter2 - yShift2 - halfHeight;
|
||||||
g2.setTransform(new AffineTransform());
|
// draw shape
|
||||||
|
drawFunction(g2, joystickColor, x2, y2, shapeJoystick);
|
||||||
float rightShoulder = event.getRightShoulder();
|
|
||||||
g2.setPaint(shoulderColor);
|
|
||||||
g2.drawRect(10, 10, 10 + Math.round(leftShoulder * 70), 10 + 20);
|
|
||||||
g2.setTransform(new AffineTransform());
|
|
||||||
|
|
||||||
event = null;
|
event = null;
|
||||||
}
|
}
|
||||||
@@ -417,6 +400,7 @@ public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel imple
|
|||||||
if (arg0 instanceof ClassicControllerEvent) {
|
if (arg0 instanceof ClassicControllerEvent) {
|
||||||
event = (ClassicControllerEvent) arg0;
|
event = (ClassicControllerEvent) arg0;
|
||||||
}
|
}
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStatusEvent(StatusEvent arg0) {
|
public void onStatusEvent(StatusEvent arg0) {
|
||||||
|
|||||||
@@ -105,19 +105,14 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements
|
|||||||
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
|
||||||
/ 180.0)
|
/ 180.0)
|
||||||
* lastJoystickEvent.getMagnitude();
|
* lastJoystickEvent.getMagnitude();
|
||||||
int dx = (int) Math.round(shape.getBounds().getWidth() / 2);
|
int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
|
||||||
int dy = (int) Math.round(shape.getBounds().getHeight() / 2);
|
int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
|
||||||
double xTemp = xAng * (xCenter - dx * 2);
|
int xAmplitude = (int)Math.round(xCenter-shape.getBounds().getWidth());
|
||||||
double yTemp = yAng * (yCenter - dy * 2);
|
int yAmplitude = (int)Math.round(xCenter-shape.getBounds().getHeight());
|
||||||
int x = xCenter - dx + (int) xTemp;
|
int xShift = (int)Math.round(xAng * xAmplitude);
|
||||||
int y = yCenter - dy - (int) yTemp;
|
int yShift = (int)Math.round(yAng * yAmplitude);
|
||||||
// System.out.println("--------------------------------------------------------------------");
|
int x = xCenter + xShift - halfWidth;
|
||||||
// System.out.println(lastJoystickEvent);
|
int y = yCenter - yShift - halHeight;
|
||||||
// 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
|
// shape
|
||||||
g2.translate(x, y);
|
g2.translate(x, y);
|
||||||
g2.setPaint(borderColor);
|
g2.setPaint(borderColor);
|
||||||
|
|||||||
Reference in New Issue
Block a user