Fix overwriting presses and releases

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 7387ced9e5
commit e05a25fc80
  1. 8
      src/sig/engine/KeyBind.java
  2. 15
      src/sig/objects/ConfigureControls.java

@ -79,23 +79,21 @@ public class KeyBind {
//Polls all KeyBinds based on device.
for (Action a : Action.values()) {
boolean held = false;
KeyBind cc = null;
for (KeyBind c : KEYBINDS.get(a)) {
held = c.isKeyHeld();
actionEventCheck(a,held);
if (held) {
cc=c;
break;
}
}
if (held) {
actionEventCheck(a,held);
/*if (held) {
if (KEYBINDS.get(a).get(0)!=cc) {
for (int i=0;i<KEYBINDS.get(a).size()-1;i++) {
KEYBINDS.get(a).set(i+1,KEYBINDS.get(a).get(i));
}
KEYBINDS.get(a).set(0,cc);
}
}
}*/
}
}

@ -5,6 +5,8 @@ import java.util.List;
import net.java.games.input.Component;
import net.java.games.input.Event;
import net.java.games.input.Component.Identifier;
import net.java.games.input.Component.POV;
import sig.RabiClone;
import sig.engine.Action;
import sig.engine.Alpha;
@ -35,10 +37,19 @@ public class ConfigureControls extends Object{
//System.out.println(c.getName()+","+c.getIdentifier()+": "+c.getPollData());
}
//System.out.println("--------");
if (RabiClone.CONTROLLERS[i].getEventQueue().getNextEvent(e)) {
while (RabiClone.CONTROLLERS[i].getEventQueue().getNextEvent(e)) {
if (assigningKey) {
List<KeyBind> clist = KeyBind.KEYBINDS.get(selectedAction);
clist.add(new KeyBind(RabiClone.CONTROLLERS[i],e.getComponent().getIdentifier(),e.getValue()));
Identifier id = e.getComponent().getIdentifier();
if (id==Identifier.Axis.POV) {
if (e.getValue()!=POV.DOWN&&
e.getValue()!=POV.RIGHT&&
e.getValue()!=POV.LEFT&&
e.getValue()!=POV.UP) {
continue; //Can't add ordinal directions, only cardinal.
}
}
clist.add(new KeyBind(RabiClone.CONTROLLERS[i],id,e.getValue()));
KeyBind.KEYBINDS.put(selectedAction,clist);
assigningKey=false;
}

Loading…
Cancel
Save