int yAxisPercentage = 0;
Component[] components = controller.getComponents();
for(int i=0; i < components.length; i++)
{
Component component = components[i];
Component.Identifier componentIdentifier = component.getIdentifier();
//System.out.println("component name: " + component.getName());
// Buttons
// Axes
if(component.isAnalog()){
float axisValue = component.getPollData();
// if (axisValue >0 && axisValue <1.5){
// axisValueInPercentage = getAxisValueInPercentageDown(axisValue, component.getName());}
// if (axisValue <0 && axisValue > -1.5){
// axisValueInPercentage = getAxisValueInPercentageUP(axisValue, component.getName());}
//System.out.println("component name axisValue: " + component.getName()+ axisValueInPercentage);
//window.txtLog.append(component.getName()+ axisValueInPercentage +"\n");
// X axis
if(componentIdentifier == Component.Identifier.Axis.X){
axisValueInPercentage = getAxisValueInPercentageX(axisValue, component.getName());
yAxisPercentage = axisValueInPercentage;
System.out.println("X: " + yAxisPercentage);
setJoystickData('X', yAxisPercentage);
continue; // Go to next component.
}
// Y axis
if(componentIdentifier == Component.Identifier.Axis.Y){
axisValueInPercentage = getAxisValueInPercentageY(axisValue, component.getName());
yAxisPercentage = axisValueInPercentage;
System.out.println("Y: " + yAxisPercentage);
setJoystickData('Y', yAxisPercentage);
continue; // Go to next component.
}
// Throtlle O
if(component.getName().contains("O")){
xAxisPercentage = getThrottleValueInPercentage(axisValue);
System.out.println("Throtlle L : " + xAxisPercentage);
setJoystickData('L', xAxisPercentage);
continue; // Go to next component.
}
// Throtlle Suwak
if(component.getName().contains("Suwak")){
xAxisPercentage = getThrottleValueInPercentage(axisValue);
System.out.println("Throtlle R : " + xAxisPercentage);
setJoystickData('P', xAxisPercentage);
continue; // Go to next component.