I need your help. I'm making a controlling program that use Wiimote, and I need to make 2 different type of control. each controller code is defined in the class controlType1 and controlType2 (which the #2 isn't included here, but mostly it is the same with #1).
the Idea is, when I press certain button on the WiiMote, the controller switched from type1 to type2. I've instantiate 2 objects, and it should removes the listener of one of the object when the button is pressed and change it to the other object.
currently, I've gone this far and get stuck here. any Idea how should I do this?
public class WiiDroneControl implements ControlSwitchListener { private Wiimote wiimote; private WiimoteListener control1 = (WiimoteListener) new controlType1(this); private WiimoteListener control2 = (WiimoteListener) new controlType2(this); public WiiDroneControl() { Wiimote wiimotes[] = WiiUseApiManager.getWiimotes(1, true); if(wiimotes!= null && wiimotes.length > 0) { wiimote = wiimotes[0]; wiimote.addWiiMoteEventListeners(control1); wiimote.addWiiMoteEventListeners(control2); wiimote.activateMotionSensing(); wiimote.activateContinuous(); wiimote.getStatus(); } } @Override public void onSwitchEvent() { // TODO Auto-generated method stub } }
and the other class
public class controlType1 implements WiimoteListener{ ControlSwitchListener listener = null; public controlType1(ControlSwitchListener l) { listener = l; } @Override public void onButtonsEvent(WiimoteButtonsEvent e) { // TODO Auto-generated method stub listener.onSwitchEvent(); if (e.isButtonOnePressed()) { //switch object when this button is pressed } } }