Begonnen met implementatie wiimote. Nu even de wiiuse dll op de goede plaats zetten.

This commit is contained in:
2011-02-08 18:45:39 +00:00
parent d31eafd99e
commit 7c51fbc05f
13 changed files with 136 additions and 34 deletions

View File

@@ -1,6 +1,8 @@
package pm.device.wiimote;
public enum WiimoteButton {
import pm.Button;
public enum WiimoteButton implements Button {
TWO (0x0001),
ONE (0x0002),
B (0x0004),
@@ -13,7 +15,7 @@ public enum WiimoteButton {
UP (0x0800),
PLUS (0x1000),
ALL (0x1F9F);
protected int code;
private WiimoteButton(int code) {

View File

@@ -0,0 +1,36 @@
package pm.device.wiimote;
import pm.Action;
import pm.Target;
import pm.device.Device;
import pm.exception.DeviceException;
import pm.exception.MacroException;
import pm.macro.event.Press;
import wiiusej.Wiimote;
public class WiimoteDevice extends Device {
protected static final int CONNECT_MAX = 10;
protected static WiimoteService wiimoteService;
protected Wiimote wiimote;
{
WiimoteDevice.wiimoteService = new WiimoteService();
}
public WiimoteDevice() throws DeviceException {
wiimote = wiimoteService.getDevice(this);
}
public void start() {
super.start();
try {
add(
new Press(WiimoteButton.A),
Action.TEST.setTarget(Target.APPLICATION));
} catch (MacroException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,67 @@
package pm.device.wiimote;
import java.util.ArrayList;
import java.util.HashMap;
import pm.exception.DeviceException;
import pm.exception.device.JavaInputDeviceNotFoundException;
import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;
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;
public class WiimoteService extends WiiUseApiManager implements WiimoteListener {
protected ArrayList<Integer> wiimoteList;
protected HashMap<Wiimote, WiimoteDevice> wiimoteMap;
WiimoteService() {
wiimoteList = new ArrayList<Integer>();
wiimoteMap = new HashMap<Wiimote, WiimoteDevice>();
}
public Wiimote getDevice(WiimoteDevice wiimoteDevice) throws DeviceException {
Wiimote[] wiimoteArray = getWiimotes(1, false);
for (Wiimote wiimote : wiimoteArray) {
int id = wiimote.getId();
if (!wiimoteList.contains(id)) {
wiimote.addWiiMoteEventListeners(this);
wiimoteList.add(id);
wiimoteMap.put(wiimote, wiimoteDevice);
return wiimote;
}
}
throw new JavaInputDeviceNotFoundException();
}
public void onButtonsEvent(WiimoteButtonsEvent event) {
//evm.macroEvent(event, getWiimote(event));
}
public void onStatusEvent(StatusEvent event) {
/*if (event.isConnected()) {
evm.event(WiimoteEvent.CONNECT, getWiimote(event));
}*/
}
public void onIrEvent(IREvent e) {}
public void onMotionSensingEvent(MotionSensingEvent event) {}
public void onExpansionEvent(ExpansionEvent event) {}
public void onDisconnectionEvent(DisconnectionEvent event) {}
public void onNunchukInsertedEvent(NunchukInsertedEvent event) {}
public void onNunchukRemovedEvent(NunchukRemovedEvent event) {}
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent event) {}
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent event) {}
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent event) {}
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent event) {}
}