Added gui and fixes for Guitar hero controller
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@184 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
BIN
WiiUseJ/img/classiccontroller.png
Normal file
BIN
WiiUseJ/img/classiccontroller.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
165
WiiUseJ/src/wiiusej/test/ClassicControllerGuiTest.java
Normal file
165
WiiUseJ/src/wiiusej/test/ClassicControllerGuiTest.java
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/**
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package wiiusej.test;
|
||||||
|
|
||||||
|
import wiiusej.Wiimote;
|
||||||
|
import wiiusej.utils.ClassicControllerButtonsEventPanel;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
|
||||||
|
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.ClassicControllerInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This frame is used to display events from a classic controller.
|
||||||
|
*
|
||||||
|
* @author guiguito
|
||||||
|
*/
|
||||||
|
public class ClassicControllerGuiTest extends javax.swing.JFrame implements WiimoteListener{
|
||||||
|
|
||||||
|
private Wiimote wiimote;
|
||||||
|
private static int MAX_SHOULDER = 100;
|
||||||
|
|
||||||
|
/** Creates new form ClassicControllerGuiTest */
|
||||||
|
public ClassicControllerGuiTest(Wiimote wiimote) {
|
||||||
|
initComponents();
|
||||||
|
this.wiimote = wiimote;
|
||||||
|
registerListeners();
|
||||||
|
leftShoulderBar.setMaximum(MAX_SHOULDER);
|
||||||
|
rightShoulderBar.setMaximum(MAX_SHOULDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
wiimote.addWiiMoteEventListeners(this);
|
||||||
|
wiimote.addWiiMoteEventListeners((ClassicControllerButtonsEventPanel)classicControllerPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unRegisterListeners() {
|
||||||
|
wiimote.removeWiiMoteEventListeners(this);
|
||||||
|
wiimote.removeWiiMoteEventListeners((ClassicControllerButtonsEventPanel)classicControllerPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
shouldersPanel = new javax.swing.JPanel();
|
||||||
|
leftShoulderBar = new javax.swing.JProgressBar();
|
||||||
|
rightShoulderBar = new javax.swing.JProgressBar();
|
||||||
|
classicControllerPanel = new wiiusej.utils.ClassicControllerButtonsEventPanel();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
setTitle("WiiuseJ Classic Controller Test GUI");
|
||||||
|
setResizable(false);
|
||||||
|
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
shouldersPanel.setLayout(new javax.swing.BoxLayout(shouldersPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
shouldersPanel.add(leftShoulderBar);
|
||||||
|
shouldersPanel.add(rightShoulderBar);
|
||||||
|
|
||||||
|
getContentPane().add(shouldersPanel);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout classicControllerPanelLayout = new javax.swing.GroupLayout(classicControllerPanel);
|
||||||
|
classicControllerPanel.setLayout(classicControllerPanelLayout);
|
||||||
|
classicControllerPanelLayout.setHorizontalGroup(
|
||||||
|
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 400, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
classicControllerPanelLayout.setVerticalGroup(
|
||||||
|
classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 284, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
|
||||||
|
getContentPane().add(classicControllerPanel);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
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 ClassicControllerEvent){
|
||||||
|
ClassicControllerEvent classicController = (ClassicControllerEvent)arg0;
|
||||||
|
float leftShoulder = classicController.getLeftShoulder();
|
||||||
|
float rightShoulder = classicController.getRightShoulder();
|
||||||
|
leftShoulderBar.setValue(Math.round(leftShoulder*MAX_SHOULDER));
|
||||||
|
rightShoulderBar.setValue(Math.round(rightShoulder*MAX_SHOULDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStatusEvent(StatusEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JPanel classicControllerPanel;
|
||||||
|
private javax.swing.JProgressBar leftShoulderBar;
|
||||||
|
private javax.swing.JProgressBar rightShoulderBar;
|
||||||
|
private javax.swing.JPanel shouldersPanel;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
172
WiiUseJ/src/wiiusej/test/GuitarHero3GuiTest.java
Normal file
172
WiiUseJ/src/wiiusej/test/GuitarHero3GuiTest.java
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* GuitarHeroGUITest.java
|
||||||
|
*
|
||||||
|
* Created on 12 juin 2008, 23:10
|
||||||
|
*/
|
||||||
|
package wiiusej.test;
|
||||||
|
|
||||||
|
import wiiusej.Wiimote;
|
||||||
|
import wiiusej.utils.GuitarHero3ButtonsEventPanel;
|
||||||
|
import wiiusej.utils.GuitarHeroJoystickEventPanel;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroButtonsEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||||
|
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This frame is used to display events from a Guitar Hero 3.
|
||||||
|
* @author guiguito
|
||||||
|
*/
|
||||||
|
public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteListener {
|
||||||
|
|
||||||
|
private Wiimote wiimote;
|
||||||
|
private static int MAX_WHAMMY_BAR = 100;
|
||||||
|
|
||||||
|
/** Creates new form GuitarHeroGUITest */
|
||||||
|
public GuitarHero3GuiTest(Wiimote wiimote) {
|
||||||
|
initComponents();
|
||||||
|
this.wiimote = wiimote;
|
||||||
|
whammyProgressBar.setMaximum(MAX_WHAMMY_BAR);
|
||||||
|
registerListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
wiimote.addWiiMoteEventListeners(this);
|
||||||
|
//register panel buttons
|
||||||
|
wiimote.addWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
|
||||||
|
//register joystick panel
|
||||||
|
wiimote.addWiiMoteEventListeners(guitarHero3JoystickPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unRegisterListeners() {
|
||||||
|
wiimote.removeWiiMoteEventListeners(this);
|
||||||
|
wiimote.removeWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
|
||||||
|
wiimote.removeWiiMoteEventListeners(guitarHero3JoystickPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
buttonsEventPanel = new javax.swing.JPanel();
|
||||||
|
guitarHero3ButtonsEventPanel = new wiiusej.utils.GuitarHero3ButtonsEventPanel();
|
||||||
|
bottomPanel = new javax.swing.JPanel();
|
||||||
|
guitarHero3JoystickPanel = new wiiusej.utils.GuitarHeroJoystickEventPanel();
|
||||||
|
whammyProgressBar = new javax.swing.JProgressBar();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
setTitle("WiiuseJ Guitar Hero 3 Test GUI");
|
||||||
|
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
buttonsEventPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
|
||||||
|
javax.swing.GroupLayout buttonsEventPanelLayout = new javax.swing.GroupLayout(buttonsEventPanel);
|
||||||
|
buttonsEventPanel.setLayout(buttonsEventPanelLayout);
|
||||||
|
buttonsEventPanelLayout.setHorizontalGroup(
|
||||||
|
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 448, Short.MAX_VALUE)
|
||||||
|
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
|
.addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)))
|
||||||
|
);
|
||||||
|
buttonsEventPanelLayout.setVerticalGroup(
|
||||||
|
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 111, Short.MAX_VALUE)
|
||||||
|
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
|
.addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)))
|
||||||
|
);
|
||||||
|
|
||||||
|
getContentPane().add(buttonsEventPanel);
|
||||||
|
|
||||||
|
bottomPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
bottomPanel.setLayout(new javax.swing.BoxLayout(bottomPanel, javax.swing.BoxLayout.X_AXIS));
|
||||||
|
bottomPanel.add(guitarHero3JoystickPanel);
|
||||||
|
|
||||||
|
whammyProgressBar.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
whammyProgressBar.setForeground(new java.awt.Color(255, 0, 255));
|
||||||
|
bottomPanel.add(whammyProgressBar);
|
||||||
|
|
||||||
|
getContentPane().add(bottomPanel);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
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 GuitarHeroEvent) {
|
||||||
|
GuitarHeroEvent guitar = (GuitarHeroEvent) arg0;
|
||||||
|
//move progress bar for whammy bar
|
||||||
|
whammyProgressBar.setValue(Math.round(MAX_WHAMMY_BAR*guitar.getWhammyBar()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStatusEvent(StatusEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JPanel bottomPanel;
|
||||||
|
private javax.swing.JPanel buttonsEventPanel;
|
||||||
|
private wiiusej.utils.GuitarHero3ButtonsEventPanel guitarHero3ButtonsEventPanel;
|
||||||
|
private wiiusej.utils.GuitarHeroJoystickEventPanel guitarHero3JoystickPanel;
|
||||||
|
private javax.swing.JProgressBar whammyProgressBar;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
@@ -363,18 +363,22 @@ public class NunchukGuiTest extends javax.swing.JFrame implements
|
|||||||
if (arg0 instanceof NunchukEvent) {
|
if (arg0 instanceof NunchukEvent) {
|
||||||
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
NunchukEvent nunchuk = (NunchukEvent) arg0;
|
||||||
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
|
||||||
|
|
||||||
|
//C button
|
||||||
if (buttons.isButtonCJustPressed()) {
|
if (buttons.isButtonCJustPressed()) {
|
||||||
cButton.setEnabled(false);
|
cButton.setEnabled(false);
|
||||||
}
|
}else if (buttons.isButtonCJustReleased()) {
|
||||||
if (buttons.isButtonCJustReleased()) {
|
|
||||||
cButton.setEnabled(true);
|
cButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
if (buttons.isButtonZJustPressed()) {
|
|
||||||
|
//Z button
|
||||||
|
if(buttons.isButtonZJustPressed()) {
|
||||||
zButton.setEnabled(false);
|
zButton.setEnabled(false);
|
||||||
}
|
}else if (buttons.isButtonZJustReleased()) {
|
||||||
if (buttons.isButtonZJustReleased()) {
|
|
||||||
zButton.setEnabled(true);
|
zButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isThresholdsRequested) {
|
if (isThresholdsRequested) {
|
||||||
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
|
||||||
nunchukAccelerationTextField.setText(evt
|
nunchukAccelerationTextField.setText(evt
|
||||||
|
|||||||
@@ -87,11 +87,13 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
showExpansionWiimoteButton.setEnabled(false);
|
showExpansionWiimoteButton.setEnabled(false);
|
||||||
showExpansionWiimoteButton.setText("Hide Nunchuk");
|
showExpansionWiimoteButton.setText("Hide Nunchuk");
|
||||||
|
//@TODO adapt to the connected Expansion
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowDeactivated(WindowEvent e) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
showExpansionWiimoteButton.setEnabled(true);
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
showExpansionWiimoteButton.setText("Show Nunchuk");
|
showExpansionWiimoteButton.setText("Show Nunchuk");
|
||||||
|
//@TODO adapt to the connected Expansion
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -235,10 +237,27 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
showExpansionWiimoteButton.setText("Show Nunchuk");
|
showExpansionWiimoteButton.setText("Show Nunchuk");
|
||||||
expansionFrame = new NunchukGuiTest(wiimote);
|
expansionFrame = new NunchukGuiTest(wiimote);
|
||||||
expansionFrame
|
expansionFrame
|
||||||
.setDefaultCloseOperation(NunchukGuiTest.HIDE_ON_CLOSE);
|
.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
expansionFrame.addWindowListener(buttonSetter);
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
isFirstStatusGot = true;
|
isFirstStatusGot = true;
|
||||||
}
|
}else if(arg0.isClassicControllerConnected()){
|
||||||
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
|
showExpansionWiimoteButton.setText("Show Classic Controller");
|
||||||
|
expansionFrame = new ClassicControllerGuiTest(wiimote);
|
||||||
|
expansionFrame
|
||||||
|
.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
|
isFirstStatusGot = true;
|
||||||
|
}
|
||||||
|
else if(arg0.isClassicControllerConnected()){
|
||||||
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
|
showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller");
|
||||||
|
expansionFrame = new GuitarHero3GuiTest(wiimote);
|
||||||
|
expansionFrame
|
||||||
|
.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
|
isFirstStatusGot = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
messageText.setText("Status received !");
|
messageText.setText("Status received !");
|
||||||
batteryLevelText.setText(arg0.getBatteryLevel() + " %");
|
batteryLevelText.setText(arg0.getBatteryLevel() + " %");
|
||||||
@@ -247,7 +266,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
led3Button.setEnabled(arg0.isLed3Set());
|
led3Button.setEnabled(arg0.isLed3Set());
|
||||||
led4Button.setEnabled(arg0.isLed4Set());
|
led4Button.setEnabled(arg0.isLed4Set());
|
||||||
if (arg0.isNunchukConnected()) {
|
if (arg0.isNunchukConnected()) {
|
||||||
((NunchukGuiTest) expansionFrame).requestThresholdsUpdate();
|
((NunchukGuiTest) expansionFrame).requestThresholdsUpdate();
|
||||||
}
|
}
|
||||||
// attachments
|
// attachments
|
||||||
int eventType = arg0.getEventType();
|
int eventType = arg0.getEventType();
|
||||||
@@ -279,7 +298,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
showExpansionWiimoteButton.setEnabled(true);
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
showExpansionWiimoteButton.setText("Show nunchuk");
|
showExpansionWiimoteButton.setText("Show nunchuk");
|
||||||
expansionFrame = new NunchukGuiTest(wiimote);
|
expansionFrame = new NunchukGuiTest(wiimote);
|
||||||
expansionFrame.setDefaultCloseOperation(NunchukGuiTest.HIDE_ON_CLOSE);
|
expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
expansionFrame.addWindowListener(buttonSetter);
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,21 +318,55 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||||
// nothing
|
messageText.setText("Guitar Hero 3 connected !");
|
||||||
|
expansionText.setText("Expansion connected : Guitar Hero 3.");
|
||||||
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
|
showExpansionWiimoteButton.setText("Show Guitar Hero 3");
|
||||||
|
expansionFrame = new GuitarHero3GuiTest(wiimote);
|
||||||
|
expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||||
// nothing
|
messageText.setText("Guitar Hero 3 disconnected !");
|
||||||
|
expansionText.setText("No expansion connected.");
|
||||||
|
showExpansionWiimoteButton.setEnabled(false);
|
||||||
|
showExpansionWiimoteButton.setText("No expansion");
|
||||||
|
if (expansionFrame != null) {
|
||||||
|
if (expansionFrame instanceof GuitarHero3GuiTest) {
|
||||||
|
((GuitarHero3GuiTest) expansionFrame).unRegisterListeners();
|
||||||
|
}
|
||||||
|
expansionFrame.setEnabled(false);
|
||||||
|
expansionFrame.dispose();
|
||||||
|
expansionFrame = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClassicControllerInsertedEvent(
|
public void onClassicControllerInsertedEvent(
|
||||||
ClassicControllerInsertedEvent arg0) {
|
ClassicControllerInsertedEvent arg0) {
|
||||||
// nothing
|
messageText.setText("Nunchuk connected !");
|
||||||
|
expansionText.setText("Expansion connected : Classic Controller.");
|
||||||
|
showExpansionWiimoteButton.setEnabled(true);
|
||||||
|
showExpansionWiimoteButton.setText("Show Classic Controller");
|
||||||
|
expansionFrame = new ClassicControllerGuiTest(wiimote);
|
||||||
|
expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
expansionFrame.addWindowListener(buttonSetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClassicControllerRemovedEvent(
|
public void onClassicControllerRemovedEvent(
|
||||||
ClassicControllerRemovedEvent arg0) {
|
ClassicControllerRemovedEvent arg0) {
|
||||||
// nothing
|
messageText.setText("Classic controller disconnected !");
|
||||||
|
expansionText.setText("No expansion connected.");
|
||||||
|
showExpansionWiimoteButton.setEnabled(false);
|
||||||
|
showExpansionWiimoteButton.setText("No expansion");
|
||||||
|
if (expansionFrame != null) {
|
||||||
|
if (expansionFrame instanceof ClassicControllerGuiTest) {
|
||||||
|
((ClassicControllerGuiTest) expansionFrame).unRegisterListeners();
|
||||||
|
}
|
||||||
|
expansionFrame.setEnabled(false);
|
||||||
|
expansionFrame.dispose();
|
||||||
|
expansionFrame = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1222,6 +1275,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
|||||||
if (expansionFrame != null) {
|
if (expansionFrame != null) {
|
||||||
if (expansionFrame instanceof NunchukGuiTest) {
|
if (expansionFrame instanceof NunchukGuiTest) {
|
||||||
((NunchukGuiTest) expansionFrame).unRegisterListeners();
|
((NunchukGuiTest) expansionFrame).unRegisterListeners();
|
||||||
|
}else if (expansionFrame instanceof ClassicControllerGuiTest) {
|
||||||
|
((ClassicControllerGuiTest) expansionFrame).unRegisterListeners();
|
||||||
}
|
}
|
||||||
expansionFrame.setEnabled(false);
|
expansionFrame.setEnabled(false);
|
||||||
expansionFrame.dispose();
|
expansionFrame.dispose();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements
|
|||||||
private Color pressedColor = Color.RED;
|
private Color pressedColor = Color.RED;
|
||||||
private Color heldColor = Color.ORANGE;
|
private Color heldColor = Color.ORANGE;
|
||||||
private Color releasedColor = Color.YELLOW;
|
private Color releasedColor = Color.YELLOW;
|
||||||
private Shape shape;
|
private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Red : button just pressed. Orange : button held.
|
* Default constructor. Red : button just pressed. Orange : button held.
|
||||||
@@ -66,7 +66,6 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements
|
|||||||
java.net.URL url = ButtonsEventPanel.class
|
java.net.URL url = ButtonsEventPanel.class
|
||||||
.getResource("/img/wiimote.png");
|
.getResource("/img/wiimote.png");
|
||||||
wiimoteImage = toolkit.createImage(url);
|
wiimoteImage = toolkit.createImage(url);
|
||||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +88,7 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements
|
|||||||
releasedColor = relColor;
|
releasedColor = relColor;
|
||||||
shape = sh;
|
shape = sh;
|
||||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||||
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
wiimoteImage = toolkit.createImage("img\\wiimote.png");
|
||||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,8 +293,7 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||||
buttons = null;
|
clearView();
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||||
|
|||||||
274
WiiUseJ/src/wiiusej/utils/GuitarHero3ButtonsEventPanel.java
Normal file
274
WiiUseJ/src/wiiusej/utils/GuitarHero3ButtonsEventPanel.java
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
/**
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package wiiusej.utils;
|
||||||
|
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroButtonsEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||||
|
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||||
|
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This panel is used to display what happens on the buttons of the
|
||||||
|
* Guitar Hero 3 controller.
|
||||||
|
* @author guiguito
|
||||||
|
*/
|
||||||
|
public class GuitarHero3ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||||
|
|
||||||
|
/** Creates new form GuitarHero3ButtonsEventPanel */
|
||||||
|
public GuitarHero3ButtonsEventPanel() {
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called from within the constructor to
|
||||||
|
* initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
* always regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
leftPanel = new javax.swing.JPanel();
|
||||||
|
plusButton = new javax.swing.JToggleButton();
|
||||||
|
minusButton = new javax.swing.JToggleButton();
|
||||||
|
strumPanel = new javax.swing.JPanel();
|
||||||
|
strumUpButton = new javax.swing.JToggleButton();
|
||||||
|
strumDownButton = new javax.swing.JToggleButton();
|
||||||
|
RightPanel = new javax.swing.JPanel();
|
||||||
|
coloredButtonsPanel = new javax.swing.JPanel();
|
||||||
|
orangeButton = new javax.swing.JToggleButton();
|
||||||
|
blueButton = new javax.swing.JToggleButton();
|
||||||
|
yellowButton = new javax.swing.JToggleButton();
|
||||||
|
redButton = new javax.swing.JToggleButton();
|
||||||
|
greenButton = new javax.swing.JToggleButton();
|
||||||
|
|
||||||
|
setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
leftPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
leftPanel.setLayout(new javax.swing.BoxLayout(leftPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
plusButton.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
plusButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
plusButton.setText("+");
|
||||||
|
leftPanel.add(plusButton);
|
||||||
|
|
||||||
|
minusButton.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
minusButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
minusButton.setText("-");
|
||||||
|
leftPanel.add(minusButton);
|
||||||
|
|
||||||
|
strumPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
strumPanel.setLayout(new javax.swing.BoxLayout(strumPanel, javax.swing.BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
strumUpButton.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
strumUpButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
strumUpButton.setText("Strum UP");
|
||||||
|
strumPanel.add(strumUpButton);
|
||||||
|
|
||||||
|
strumDownButton.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
strumDownButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
strumDownButton.setText("Strum DOWN");
|
||||||
|
strumPanel.add(strumDownButton);
|
||||||
|
|
||||||
|
leftPanel.add(strumPanel);
|
||||||
|
|
||||||
|
add(leftPanel);
|
||||||
|
|
||||||
|
RightPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
RightPanel.setLayout(new javax.swing.BoxLayout(RightPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
coloredButtonsPanel.setLayout(new javax.swing.BoxLayout(coloredButtonsPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
orangeButton.setBackground(new java.awt.Color(255, 153, 0));
|
||||||
|
orangeButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
orangeButton.setText("O");
|
||||||
|
coloredButtonsPanel.add(orangeButton);
|
||||||
|
|
||||||
|
blueButton.setBackground(new java.awt.Color(0, 0, 204));
|
||||||
|
blueButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
blueButton.setText("O");
|
||||||
|
coloredButtonsPanel.add(blueButton);
|
||||||
|
|
||||||
|
yellowButton.setBackground(new java.awt.Color(255, 255, 0));
|
||||||
|
yellowButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
yellowButton.setText("O");
|
||||||
|
coloredButtonsPanel.add(yellowButton);
|
||||||
|
|
||||||
|
redButton.setBackground(new java.awt.Color(255, 0, 0));
|
||||||
|
redButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
redButton.setText("O");
|
||||||
|
coloredButtonsPanel.add(redButton);
|
||||||
|
|
||||||
|
greenButton.setBackground(new java.awt.Color(51, 255, 0));
|
||||||
|
greenButton.setFont(new java.awt.Font("Arial", 1, 24));
|
||||||
|
greenButton.setText("O");
|
||||||
|
coloredButtonsPanel.add(greenButton);
|
||||||
|
|
||||||
|
RightPanel.add(coloredButtonsPanel);
|
||||||
|
|
||||||
|
add(RightPanel);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onIrEvent(IREvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||||
|
if (arg0 instanceof GuitarHeroEvent) {
|
||||||
|
GuitarHeroEvent guitar = (GuitarHeroEvent) arg0;
|
||||||
|
GuitarHeroButtonsEvent buttons = guitar.getButtonsEvent();
|
||||||
|
|
||||||
|
//orange button
|
||||||
|
if (buttons.isButtonOrangeJustPressed()) {
|
||||||
|
orangeButton.setSelected(true);
|
||||||
|
orangeButton.setText("X");
|
||||||
|
} else if (buttons.isButtonOrangeJustReleased()) {
|
||||||
|
orangeButton.setSelected(false);
|
||||||
|
orangeButton.setText("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
//blue button
|
||||||
|
if (buttons.isButtonBlueJustPressed()) {
|
||||||
|
blueButton.setSelected(true);
|
||||||
|
orangeButton.setText("X");
|
||||||
|
} else if (buttons.isButtonBlueJustReleased()) {
|
||||||
|
blueButton.setSelected(false);
|
||||||
|
orangeButton.setText("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Yellow button
|
||||||
|
if (buttons.isButtonYellowJustPressed()) {
|
||||||
|
yellowButton.setSelected(true);
|
||||||
|
yellowButton.setText("X");
|
||||||
|
} else if (buttons.isButtonYellowJustReleased()) {
|
||||||
|
yellowButton.setSelected(false);
|
||||||
|
yellowButton.setText("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Red button
|
||||||
|
if (buttons.isButtonRedJustPressed()) {
|
||||||
|
redButton.setSelected(true);
|
||||||
|
redButton.setText("X");
|
||||||
|
} else if (buttons.isButtonRedJustReleased()) {
|
||||||
|
redButton.setSelected(false);
|
||||||
|
redButton.setText("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Green button
|
||||||
|
if (buttons.isButtonGreenJustPressed()) {
|
||||||
|
greenButton.setSelected(true);
|
||||||
|
greenButton.setText("X");
|
||||||
|
} else if (buttons.isButtonGreenJustReleased()) {
|
||||||
|
greenButton.setSelected(false);
|
||||||
|
greenButton.setText("O");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Plus button
|
||||||
|
if (buttons.isButtonPlusJustPressed()) {
|
||||||
|
plusButton.setSelected(true);
|
||||||
|
} else if (buttons.isButtonPlusJustReleased()) {
|
||||||
|
plusButton.setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Minus button
|
||||||
|
if (buttons.isButtonMinusJustPressed()) {
|
||||||
|
minusButton.setSelected(true);
|
||||||
|
} else if (buttons.isButtonMinusJustReleased()) {
|
||||||
|
minusButton.setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Strum up button
|
||||||
|
if (buttons.isButtonStrumUpJustPressed()) {
|
||||||
|
strumUpButton.setSelected(true);
|
||||||
|
} else if (buttons.isButtonStrumUpJustReleased()) {
|
||||||
|
strumUpButton.setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Strum down button
|
||||||
|
if (buttons.isButtonStrumDownJustPressed()) {
|
||||||
|
strumDownButton.setSelected(true);
|
||||||
|
} else if (buttons.isButtonStrumDownJustReleased()) {
|
||||||
|
strumDownButton.setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStatusEvent(StatusEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JPanel RightPanel;
|
||||||
|
private javax.swing.JToggleButton blueButton;
|
||||||
|
private javax.swing.JPanel coloredButtonsPanel;
|
||||||
|
private javax.swing.JToggleButton greenButton;
|
||||||
|
private javax.swing.JPanel leftPanel;
|
||||||
|
private javax.swing.JToggleButton minusButton;
|
||||||
|
private javax.swing.JToggleButton orangeButton;
|
||||||
|
private javax.swing.JToggleButton plusButton;
|
||||||
|
private javax.swing.JToggleButton redButton;
|
||||||
|
private javax.swing.JToggleButton strumDownButton;
|
||||||
|
private javax.swing.JPanel strumPanel;
|
||||||
|
private javax.swing.JToggleButton strumUpButton;
|
||||||
|
private javax.swing.JToggleButton yellowButton;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
39
WiiUseJ/src/wiiusej/utils/GuitarHeroJoystickEventPanel.java
Normal file
39
WiiUseJ/src/wiiusej/utils/GuitarHeroJoystickEventPanel.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package wiiusej.utils;
|
||||||
|
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||||
|
import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Panel to display Guitar Hero 3 controller joystick events.
|
||||||
|
*
|
||||||
|
* @author guiguito
|
||||||
|
*/
|
||||||
|
public class GuitarHeroJoystickEventPanel extends JoystickEventPanel{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||||
|
if (e instanceof GuitarHeroEvent){
|
||||||
|
return ((GuitarHeroEvent)e).getGuitarHeroJoystickEvent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -155,7 +155,7 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||||
JoystickEvent joy = getJoystikEvent(arg0);
|
JoystickEvent joy = getJoystickEvent(arg0);
|
||||||
if (joy != null) {
|
if (joy != null) {
|
||||||
lastJoystickEvent = joy;
|
lastJoystickEvent = joy;
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements
|
|||||||
this.shape = shape;
|
this.shape = shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract JoystickEvent getJoystikEvent(ExpansionEvent e);
|
public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called from within the constructor to initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +29,7 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
|||||||
public class NunchukJoystickEventPanel extends JoystickEventPanel {
|
public class NunchukJoystickEventPanel extends JoystickEventPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JoystickEvent getJoystikEvent(ExpansionEvent e) {
|
public JoystickEvent getJoystickEvent(ExpansionEvent e) {
|
||||||
if (e instanceof NunchukEvent) {
|
if (e instanceof NunchukEvent) {
|
||||||
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
return ((NunchukEvent) e).getNunchukJoystickEvent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class ClassicControllerEvent extends ExpansionEvent {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String out = "";
|
String out = "";
|
||||||
/* Status */
|
/* Status */
|
||||||
out += "/*********** Classis Controller EVENT : WIIMOTE ID :"
|
out += "/*********** Classic Controller EVENT : WIIMOTE ID :"
|
||||||
+ getWiimoteId() + " ********/\n";
|
+ getWiimoteId() + " ********/\n";
|
||||||
out += buttonsEvent;
|
out += buttonsEvent;
|
||||||
out += "Left shoulder : " + leftShoulder + "\n";
|
out += "Left shoulder : " + leftShoulder + "\n";
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class GuitarHeroEvent extends ExpansionEvent{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String out = "";
|
String out = "";
|
||||||
/* Status */
|
/* Status */
|
||||||
out += "/*********** Classis Controller EVENT : WIIMOTE ID :" + getWiimoteId()
|
out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||||
+ " ********/\n";
|
+ " ********/\n";
|
||||||
out += buttonsEvent;
|
out += buttonsEvent;
|
||||||
out += "Whammy Bar : "+whammyBar+"\n";
|
out += "Whammy Bar : "+whammyBar+"\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user