Verder gewerkt aan implementatie wiimote.
This commit is contained in:
@@ -7,6 +7,7 @@ import pm.exception.DeviceException;
|
||||
import pm.exception.MacroException;
|
||||
import pm.macro.event.Press;
|
||||
import wiiusej.Wiimote;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
|
||||
public class WiimoteDevice extends Device {
|
||||
protected static final int CONNECT_MAX = 10;
|
||||
@@ -33,4 +34,8 @@ public class WiimoteDevice extends Device {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent event) {
|
||||
//evm.macroEvent(event, getWiimote(event));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import pm.exception.DeviceException;
|
||||
import pm.exception.device.JavaInputDeviceNotFoundException;
|
||||
import wiiusej.WiiUseApiManager;
|
||||
import wiiusej.Wiimote;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
@@ -23,11 +24,23 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
public class WiimoteService extends WiiUseApiManager implements WiimoteListener {
|
||||
protected ArrayList<Integer> wiimoteList;
|
||||
protected HashMap<Wiimote, WiimoteDevice> wiimoteMap;
|
||||
protected Wiimote[] wiimoteArray;
|
||||
protected HashMap<Integer, WiimoteDevice> wiimoteDeviceMap;
|
||||
|
||||
WiimoteService() {
|
||||
wiimoteList = new ArrayList<Integer>();
|
||||
wiimoteMap = new HashMap<Wiimote, WiimoteDevice>();
|
||||
wiimoteArray = new Wiimote[0];
|
||||
wiimoteDeviceMap = new HashMap<Integer, WiimoteDevice>();
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
// Todo: methode bedenken om deze methode aangeroepen te krijgen, zonder de service in de main te hoeven registreren.
|
||||
if (wiimoteArray != null) {
|
||||
for (Wiimote wiimote : wiimoteArray) {
|
||||
wiimote.disconnect();
|
||||
}
|
||||
}
|
||||
definitiveShutdown();
|
||||
}
|
||||
|
||||
public Wiimote getDevice(WiimoteDevice wiimoteDevice) throws DeviceException {
|
||||
@@ -37,21 +50,29 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
|
||||
if (!wiimoteList.contains(id)) {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
wiimoteList.add(id);
|
||||
wiimoteMap.put(wiimote, wiimoteDevice);
|
||||
wiimoteDeviceMap.put(id, wiimoteDevice); // Todo: controleren of dit nodig is. Ligt aan hoe uniek het id is na bijvoorbeeld een reconnect. Wellicht voldoet een arrayList ook.
|
||||
return wiimote;
|
||||
}
|
||||
}
|
||||
throw new JavaInputDeviceNotFoundException();
|
||||
}
|
||||
|
||||
public Wiimote getWiimote(GenericEvent event) {
|
||||
return wiimoteArray[event.getWiimoteId() - 1];
|
||||
}
|
||||
|
||||
public WiimoteDevice getWiimoteDevice(GenericEvent event){
|
||||
return wiimoteDeviceMap.get(event.getWiimoteId());
|
||||
}
|
||||
|
||||
public void onButtonsEvent(WiimoteButtonsEvent event) {
|
||||
//evm.macroEvent(event, getWiimote(event));
|
||||
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent event) {
|
||||
/*if (event.isConnected()) {
|
||||
evm.event(WiimoteEvent.CONNECT, getWiimote(event));
|
||||
}*/
|
||||
if (event.isConnected()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent e) {}
|
||||
|
||||
Reference in New Issue
Block a user