// FIXME - switch statement (it's Java 7 !)
for (int i = 0; i < components.length; i++) {
Component component = components[i];
Identifier id = component.getIdentifier();
String n = components[i].getName();
float data = components[i].getPollData();
// buffer.append(n);
// TODO - invoke based on
// invoke(String.trim(component.getName()),
// mapMultiplier(getName()), mapOffset(getName()) - REFACTOR
// REFACTOR !!! use switch statement
if (Identifier.Axis.Z.equals(id)) {
if (lastValues[i] != data) {
if (ZAxisTransform) {
invoke("ZAxis", (int) (ZAxisMultiplier * data) + ZAxisOffset);
} else {
invoke("ZAxisRaw", data);
}
}
} else if (Identifier.Axis.RZ.equals(id)) {
if (lastValues[i] != data) {
if (ZRotTransform) {
invoke("ZRotation", (int) (ZRotMultiplier * data) + ZRotOffset);
} else {
invoke("ZRotationRaw", data);
}
}
} else if (Identifier.Axis.X.equals(id)) {
if (lastValues[i] != data) {
if (XAxisTransform) {
invoke("XAxis", (int) (XAxisMultiplier * data) + XAxisOffset);
} else {
invoke("XAxisRaw", data);
}
}
} else if (Identifier.Axis.Y.equals(id)) {
if (lastValues[i] != data) {
if (YAxisTransform) {
invoke("YAxis", (int) (YAxisMultiplier * data) + YAxisOffset);
} else {
invoke("YAxisRaw", data);
}
}
} else if (Identifier.Axis.POV.equals(id)) {
if (lastValues[i] != data) {
if (hatTransform) {
invoke("hatSwitch", (int) (hatMultiplier * data) + hatOffset);
} else {
invoke("hatSwitchRaw", data);
}
}
} else if (Identifier.Axis.SLIDER.equals(id)) {
if (lastValues[i] != data) {
if (sliderTransform) {
invoke("slider", (int) (sliderMultiplier * data) + sliderOffset);
} else {
invoke("sliderRaw", data);
System.out.println("sliderRaw" + data);
}
}
// WTF ??? - A on Linux _0 on Windows, really? I mean
// really? Why?
} else if (Identifier.Button.A.equals(id) || Identifier.Button._0.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button1", pos);
}
} else if (Identifier.Button.B.equals(id) || Identifier.Button._1.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button2", pos);
}
} else if (Identifier.Button.C.equals(id) || Identifier.Button._2.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button3", pos);
}
} else if (Identifier.Button.X.equals(id) || Identifier.Button._3.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button4", pos);
}
} else if (Identifier.Button.Y.equals(id) || Identifier.Button._4.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button5", pos);
}
} else if (Identifier.Button.Z.equals(id) || Identifier.Button._5.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button6", pos);
}
} else if (Identifier.Button.LEFT_THUMB.equals(id) || Identifier.Button._6.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button7", pos);
}
} else if (Identifier.Button.RIGHT_THUMB.equals(id) || Identifier.Button._7.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button8", pos);
}
} else if (Identifier.Button.LEFT_THUMB2.equals(id) || Identifier.Button._8.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button9", pos);
}
} else if (Identifier.Button.RIGHT_THUMB2.equals(id) || Identifier.Button._9.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button10", pos);
}
} else if (Identifier.Button.SELECT.equals(id) || Identifier.Button._10.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button11", pos);
}
} else if (Identifier.Button.UNKNOWN.equals(id) || Identifier.Button._11.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button12", pos);
}
} else if (Identifier.Button._12.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button13", pos);
}
} else if (Identifier.Button._13.equals(id)) {
int pos = (int) data;
if (lastValues[i] != data) {
invoke("button14", pos);
}
} else {
System.out.println(String.format("unknown identifier %s", id.toString()));
}
lastValues[i] = data;
System.out.println("kierunek XY: " + getXYStickDir()+ " " + comps[xAxisIdx].getPollData() + " " + comps[yAxisIdx].getPollData());