|
|
@ -12,21 +12,21 @@ public class KeyBind { |
|
|
|
public static HashMap<Action,List<KeyBind>> KEYBINDS = new HashMap<>(); |
|
|
|
public static HashMap<Action,List<KeyBind>> KEYBINDS = new HashMap<>(); |
|
|
|
static HashMap<Action,Boolean> KEYS = new HashMap<>(); |
|
|
|
static HashMap<Action,Boolean> KEYS = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
public Controller c; |
|
|
|
public byte port; |
|
|
|
public Identifier id; |
|
|
|
public Identifier id; |
|
|
|
float val; |
|
|
|
float val; |
|
|
|
|
|
|
|
|
|
|
|
public KeyBind(Controller c, Identifier id) { |
|
|
|
public KeyBind(byte port, Identifier id) { |
|
|
|
this.c=c; |
|
|
|
this.port=port; |
|
|
|
this.id=id; |
|
|
|
this.id=id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public KeyBind(int keycode) { |
|
|
|
public KeyBind(int keycode) { |
|
|
|
this(null,new Key(keycode)); |
|
|
|
this((byte)-1,new Key(keycode)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public KeyBind(Controller c, Identifier id, float val) { |
|
|
|
public KeyBind(byte port, Identifier id, float val) { |
|
|
|
this.c=c; |
|
|
|
this.port=port; |
|
|
|
this.id=id; |
|
|
|
this.id=id; |
|
|
|
this.val=val; |
|
|
|
this.val=val; |
|
|
|
} |
|
|
|
} |
|
|
@ -34,39 +34,39 @@ public class KeyBind { |
|
|
|
public boolean isKeyHeld() { |
|
|
|
public boolean isKeyHeld() { |
|
|
|
if (id instanceof Key) { |
|
|
|
if (id instanceof Key) { |
|
|
|
return ((Key)id).isKeyHeld(); |
|
|
|
return ((Key)id).isKeyHeld(); |
|
|
|
} else if (id instanceof Identifier.Button) { |
|
|
|
} else if (RabiClone.CONTROLLERS.length>port && id instanceof Identifier.Button) { |
|
|
|
return c.getComponent(id).getPollData()>0.0f; |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getPollData()>0.0f; |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (c.getComponent(id).getIdentifier()==Identifier.Axis.POV) { |
|
|
|
if (RabiClone.CONTROLLERS.length>port && RabiClone.CONTROLLERS[port].getComponent(id).getIdentifier()==Identifier.Axis.POV) { |
|
|
|
if (val==POV.DOWN) { |
|
|
|
if (val==POV.DOWN) { |
|
|
|
return c.getComponent(id).getPollData()==POV.DOWN|| |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.DOWN|| |
|
|
|
c.getComponent(id).getPollData()==POV.DOWN_LEFT|| |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.DOWN_LEFT|| |
|
|
|
c.getComponent(id).getPollData()==POV.DOWN_RIGHT; |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.DOWN_RIGHT; |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (val==POV.UP) { |
|
|
|
if (val==POV.UP) { |
|
|
|
return c.getComponent(id).getPollData()==POV.UP|| |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.UP|| |
|
|
|
c.getComponent(id).getPollData()==POV.UP_LEFT|| |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.UP_LEFT|| |
|
|
|
c.getComponent(id).getPollData()==POV.UP_RIGHT; |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.UP_RIGHT; |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (val==POV.RIGHT) { |
|
|
|
if (val==POV.RIGHT) { |
|
|
|
return c.getComponent(id).getPollData()==POV.RIGHT|| |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.RIGHT|| |
|
|
|
c.getComponent(id).getPollData()==POV.UP_RIGHT|| |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.UP_RIGHT|| |
|
|
|
c.getComponent(id).getPollData()==POV.DOWN_RIGHT; |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.DOWN_RIGHT; |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (val==POV.LEFT) { |
|
|
|
if (val==POV.LEFT) { |
|
|
|
return c.getComponent(id).getPollData()==POV.LEFT|| |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.LEFT|| |
|
|
|
c.getComponent(id).getPollData()==POV.DOWN_LEFT|| |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.DOWN_LEFT|| |
|
|
|
c.getComponent(id).getPollData()==POV.UP_LEFT; |
|
|
|
RabiClone.CONTROLLERS[port].getComponent(id).getPollData()==POV.UP_LEFT; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
System.err.println("Unexpected value for POV! Must be a cardinal direction! Given value: "+val); |
|
|
|
System.err.println("Unexpected value for POV! Must be a cardinal direction! Given value: "+val); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (id instanceof Identifier.Axis) { |
|
|
|
if (RabiClone.CONTROLLERS.length>port && id instanceof Identifier.Axis) { |
|
|
|
return Math.abs(c.getComponent(id).getPollData())>=c.getComponent(id).getDeadZone()&&Math.signum(c.getComponent(id).getPollData())==Math.signum(val); |
|
|
|
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone()&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
System.out.println("Could not find proper recognition for component "+id.getName()); |
|
|
|
//System.out.println("Could not find proper recognition for component "+id.getName());
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -125,8 +125,8 @@ public class KeyBind { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
|
if (c!=null) { |
|
|
|
if (RabiClone.CONTROLLERS.length>port&&port!=-1) { |
|
|
|
return c.getComponent(id).getName(); |
|
|
|
return RabiClone.CONTROLLERS[port].getComponent(id).getName(); |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (id instanceof Key) { |
|
|
|
if (id instanceof Key) { |
|
|
|
return ((Key)id).getName(); |
|
|
|
return ((Key)id).getName(); |
|
|
|