Introductie EightfoldDirection in plaats van duplicate TypeDirection enums bij JavaInputDevice's.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package pm.device.javainput.extreme3d;
|
||||
package pm.device.javainput;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
import pm.Button;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
public enum Extreme3DDirection implements Button {
|
||||
public enum EightfoldDirection implements Button {
|
||||
NORTH (0),
|
||||
NORTHEAST (45),
|
||||
EAST (90),
|
||||
@@ -16,7 +16,7 @@ public enum Extreme3DDirection implements Button {
|
||||
|
||||
protected int code;
|
||||
|
||||
private Extreme3DDirection(int code) {
|
||||
private EightfoldDirection(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public enum Extreme3DDirection implements Button {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static Extreme3DDirection create(int angle) throws UnknownDirectionException {
|
||||
for (Extreme3DDirection button : Extreme3DDirection.values()) {
|
||||
public static EightfoldDirection create(int angle) throws UnknownDirectionException {
|
||||
for (EightfoldDirection button : EightfoldDirection.values()) {
|
||||
if (button.getCode() == angle) {
|
||||
return button;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public enum Extreme3DDirection implements Button {
|
||||
throw new UnknownDirectionException();
|
||||
}
|
||||
|
||||
public static Extreme3DDirection create(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
public static EightfoldDirection create(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return create(event.getDirectional().getDirection() / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import pm.Action;
|
||||
import pm.Button;
|
||||
import pm.Macro;
|
||||
import pm.Target;
|
||||
import pm.device.javainput.EightfoldDirection;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.MacroException;
|
||||
@@ -45,6 +46,6 @@ public class Extreme3DDevice extends JavaInputDevice {
|
||||
}
|
||||
|
||||
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return Extreme3DDirection.create(event);
|
||||
return EightfoldDirection.create(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package pm.device.javainput.rumblepad;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
import pm.Action;
|
||||
import pm.Button;
|
||||
import pm.Macro;
|
||||
import pm.Target;
|
||||
import pm.device.javainput.EightfoldDirection;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.MacroException;
|
||||
import pm.exception.event.UnknownButtonException;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
import pm.macro.event.Press;
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
public class RumblepadDevice extends JavaInputDevice {
|
||||
|
||||
@@ -48,7 +49,6 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
}
|
||||
|
||||
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return RumblepadDirection.create(event);
|
||||
return EightfoldDirection.create(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package pm.device.javainput.rumblepad;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
import pm.Button;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
|
||||
public enum RumblepadDirection implements Button {
|
||||
NORTH (0),
|
||||
NORTHEAST (45),
|
||||
EAST (90),
|
||||
SOUTHEAST (135),
|
||||
SOUTH (180),
|
||||
SOUTHWEST (225),
|
||||
WEST (270),
|
||||
NORTHWEST (315);
|
||||
|
||||
protected int code;
|
||||
|
||||
private RumblepadDirection(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static RumblepadDirection create(int angle) throws UnknownDirectionException {
|
||||
for (RumblepadDirection button : RumblepadDirection.values()) {
|
||||
if (button.getCode() == angle) {
|
||||
return button;
|
||||
}
|
||||
}
|
||||
throw new UnknownDirectionException();
|
||||
}
|
||||
|
||||
public static RumblepadDirection create(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return create(event.getDirectional().getDirection() / 100);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user