bindingSaves.put(nextBind.key, String.format("py:%s",posVal?"+":"-"));
}
boolean bind( ControlBinding nextBind) {
boolean bound = false;
Controller cont = Controllers.getEventSource();
String alreadyBound = "";
//Unbind a value if it is being remapped
int index = Controllers.getEventControlIndex();
if( revAxisBinds.containsKey(nextBind)) {
alreadyBound = cont.getAxisName(revAxisBinds.get(nextBind).getLeft())+" axis";
if( nextBind.isBiAxis() ) {
int axis_index = revAxisBinds.get(nextBind).getKey();
axisBinds.remove( Pair.of(axis_index, true ) );
axisBinds.remove( Pair.of(axis_index, false) );
} else {
axisBinds.remove( revAxisBinds.get(nextBind));
}
revAxisBinds.remove( nextBind );
}
if( revButtonBinds.containsKey(nextBind)) {
Integer button = revButtonBinds.get(nextBind);
alreadyBound = cont.getButtonName(button)+" button";
buttonBinds.remove(button);
revButtonBinds.remove( nextBind );
}
if( povXBindPos == nextBind ) {
povXBindPos = null;
alreadyBound = "POV X+";
} else if( povYBindPos == nextBind ) {
povYBindPos = null;
alreadyBound = "POV Y+";
} else if( povXBindNeg == nextBind ) {
povXBindNeg = null;
alreadyBound = "POV X-";
} else if( povYBindNeg == nextBind ) {
povYBindNeg = null;
alreadyBound = "POV Y-";
}
if( !alreadyBound.isEmpty() )
System.out.println( nextBind.getDescription()+" already bound to "+alreadyBound+". Removing.");
//Bind to value
if( Controllers.isEventAxis() ) {
float joyVal = cont.getAxisValue(index);
boolean posVal = joyVal>0;
if(Math.abs(joyVal)>0.5f) {
bindAxis( nextBind, index, posVal, cont.getAxisName(index));
bound = true;
}
} else if( Controllers.isEventButton() ) {
if( cont.isButtonPressed(index)) {
bindButton( nextBind, index, cont.getButtonName(index) );
bound = true;
}
} else if( Controllers.isEventPovX()) {
if( cont.getPovX() != 0)
{
bindPovX(nextBind, cont.getPovX() > 0);
bound = true;
}
} else if( Controllers.isEventPovY()) {
if( cont.getPovY() != 0)
{
bindPovY(nextBind, cont.getPovY() > 0);
bound = true;
}
}
return bound;
}