Begonnen met implementatie wiimote. Nu even de wiiuse dll op de goede plaats zetten.
This commit is contained in:
@@ -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) {
|
||||
|
||||
36
java/src/pm/device/wiimote/WiimoteDevice.java
Normal file
36
java/src/pm/device/wiimote/WiimoteDevice.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
67
java/src/pm/device/wiimote/WiimoteService.java
Normal file
67
java/src/pm/device/wiimote/WiimoteService.java
Normal 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) {}
|
||||
}
|
||||
Reference in New Issue
Block a user