This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Queue;
|
||||
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
import pm.macro.MacroListener;
|
||||
|
||||
public abstract class Device {
|
||||
protected static Queue<Actions> actionQueue;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package pm.device;
|
||||
|
||||
import pm.Macro;
|
||||
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
|
||||
|
||||
public class MacroListener extends Thread {
|
||||
public void add(Macro macro, Actions action, Targets target) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,21 @@ import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
import pm.Button;
|
||||
import pm.device.Device;
|
||||
import pm.device.javainput.extreme3d.Extreme3DButton;
|
||||
import pm.device.javainput.extreme3d.Extreme3DDirection;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.EventException;
|
||||
import pm.exception.device.JavaInputDeviceNotFoundException;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
import pm.macro.event.Press;
|
||||
import pm.macro.event.Release;
|
||||
|
||||
public abstract class JavaInputDevice extends Device {
|
||||
protected JavaInputListener javaInputListener;
|
||||
//protected JXInputDevice jxinputDevice;
|
||||
protected Button previousDirectionalButton;
|
||||
|
||||
protected JavaInputDevice(String name) throws DeviceException {
|
||||
super();
|
||||
@@ -25,6 +31,10 @@ public abstract class JavaInputDevice extends Device {
|
||||
javaInputListener.start();
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
javaInputListener.exit();
|
||||
}
|
||||
|
||||
public static JXInputDevice getDevice(String name) throws DeviceException {
|
||||
int numberOfDevices = JXInputManager.getNumberOfDevices();
|
||||
for (int i = 0; i < numberOfDevices; ++i) {
|
||||
@@ -36,7 +46,41 @@ public abstract class JavaInputDevice extends Device {
|
||||
throw new JavaInputDeviceNotFoundException();
|
||||
}
|
||||
|
||||
public void processEvent(JXInputAxisEvent event) {}
|
||||
public void processEvent(JXInputButtonEvent event) throws EventException {}
|
||||
public void processEvent(JXInputDirectionalEvent event) throws EventException {}
|
||||
public void processEvent(JXInputAxisEvent event) {
|
||||
//addAction(Action.START, Target.APPLICATION);
|
||||
//System.out.println(event);
|
||||
}
|
||||
|
||||
public void processEvent(JXInputButtonEvent event) throws EventException {
|
||||
//addAction(Action.TEST, Target.APPLICATION);
|
||||
Button button = Extreme3DButton.create(event);
|
||||
if (event.getButton().getState()) {
|
||||
System.out.println("Press: " + button);
|
||||
macroListener.add(new Press(button));
|
||||
} else {
|
||||
System.out.println("Release: " + button);
|
||||
macroListener.add(new Release(button));
|
||||
}
|
||||
//System.out.println(button);
|
||||
//System.out.println(button.getType() + " " + button.getName() +" " + );
|
||||
}
|
||||
|
||||
public void processEvent(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
//addAction(Action.EXIT, Target.APPLICATION);
|
||||
//Directional directional = event.getDirectional();
|
||||
Button button = Extreme3DDirection.create(event);
|
||||
if (event.getDirectional().isCentered()) {
|
||||
if (previousDirectionalButton != null) {
|
||||
System.out.println("Release: " + previousDirectionalButton);
|
||||
macroListener.add(new Release(previousDirectionalButton));
|
||||
}
|
||||
} else {
|
||||
System.out.println("Press: " + button);
|
||||
macroListener.add(new Press(button));
|
||||
previousDirectionalButton = button;
|
||||
}
|
||||
//System.out.println(Extreme3DDirection.create(event));
|
||||
//System.out.println(Extreme3DButton.create(event));
|
||||
//System.out.println(directional.isCentered() + " " + directional.getValue() + " [" + directional.getName() + "] " + directional.getResolution() + " " + directional.getDirection());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,4 +98,8 @@ public class JavaInputListener extends Thread implements JXInputAxisEventListene
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
run = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package pm.device.javainput.extreme3d;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
import pm.Macro;
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.EventException;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
import pm.exception.MacroException;
|
||||
import pm.macro.event.Hold;
|
||||
import pm.macro.event.Press;
|
||||
import pm.macro.event.Release;
|
||||
|
||||
public class Extreme3DDevice extends JavaInputDevice {
|
||||
|
||||
@@ -20,42 +20,17 @@ public class Extreme3DDevice extends JavaInputDevice {
|
||||
|
||||
public void start() {
|
||||
super.start();
|
||||
macroListener.addMacro(
|
||||
new Macro(
|
||||
new Hold(Button.A),
|
||||
new Press(Button.B),
|
||||
new Press(Button.TWO),
|
||||
new Release(Button.A)),
|
||||
Action.EXIT, Target.APPLICATION));
|
||||
}
|
||||
|
||||
public void processEvent(JXInputAxisEvent event) {
|
||||
//addAction(Action.START, Target.APPLICATION);
|
||||
//System.out.println(event);
|
||||
}
|
||||
|
||||
public void processEvent(JXInputButtonEvent event) throws EventException {
|
||||
//addAction(Action.TEST, Target.APPLICATION);
|
||||
if (event.getButton().getState()) {
|
||||
// press
|
||||
} else {
|
||||
// release
|
||||
try {
|
||||
macroListener.add(
|
||||
new Macro(
|
||||
new Hold(Extreme3DButton.ONE),
|
||||
new Press(Extreme3DButton.TWO),
|
||||
new Press(Extreme3DButton.ELEVEN),
|
||||
new Release(Extreme3DButton.ONE)),
|
||||
Actions.EXIT,
|
||||
Targets.MAIN);
|
||||
} catch (MacroException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(Extreme3DButton.create(event));
|
||||
//System.out.println(button.getType() + " " + button.getName() +" " + );
|
||||
}
|
||||
|
||||
public void processEvent(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
//addAction(Action.EXIT, Target.APPLICATION);
|
||||
//Directional directional = event.getDirectional();
|
||||
if (event.getDirectional().isCentered()) {
|
||||
// release
|
||||
} else {
|
||||
// press
|
||||
}
|
||||
System.out.println(Extreme3DDirection.create(event));
|
||||
//System.out.println(Extreme3DButton.create(event));
|
||||
//System.out.println(directional.isCentered() + " " + directional.getValue() + " [" + directional.getName() + "] " + directional.getResolution() + " " + directional.getDirection());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user