Still trying to get the custom joystick working. Have a test test Processing script to access it but the returned data does not change. Here is the setup:
Arduino Micro reading pots via Joystick library
The Arduino is showing up in Windows 10 Game Controllers as “Pololu A-Star 32U4” - which is the previous 32U4 I’ve used.
When I use the Win Game Controller config - it responds to moving of the pots as expected.
In the GameControlPlus configurator I see the pots moving from -1 to 1 as expected.
So what am I missing that I get no changes in the script?
Below is the full test script.
// Libraries for GameControl Plus
import org.gamecontrolplus.gui.*;
import org.gamecontrolplus.*;
import net.java.games.input.*;
import processing.serial.*;
//import java.util.Timer;
//import java.util.TimerTask;
ControlIO control;
ControlDevice stick;
float x,y;
float JOYX, JOYY; // New Joystick coords
float BUTTX, BUTTY; // Joy coords at button press
float cartX, cartY; // joystick as Cartesean coords
float px, py;
float ajx, ajy, th0, th1, th2, X, Y;
float bx0, by0, bx1, by1, bx2, by2;
float dx0, dy0, dx1, dy1, dx2, dy2;
void settings(){
//fullScreen();
size(250, 250); // 950 good on 17"mon
}
void setup(){
control = ControlIO.getInstance(this);
stick = control.getMatchedDevice("JoyTest2");
//stick.getButton("But0").plug(this, "readStick", ControlIO.ON_RELEASE); // Must get info from Quark on this function
//stick.getButton("But1").plug(this, "keyPressed", ControlIO.ON_RELEASE); // Aux buttons for reset and whatever
}
void draw(){
getUserInput();
noStroke();
fill(255, 64, 64, 64);
ellipse(px, py, 20, 20);
print("X: ", JOYX);
println(" Y: ", JOYY);
println("");
print("cartX: ", cartX);
println(" cartY: ",cartY);
delay(500);
}
void getUserInput() {
X = stick.getSlider("Xaxis").getValue();
Y = stick.getSlider("Yaxis").getValue();
px = map(stick.getSlider("Xaxis").getValue(), -1, 1, 0, width);
py = map(stick.getSlider("Yaxis").getValue(), -1, 1, 0, height);
ajx = map(X, -1, 1, 0, width);
ajy = map(Y, -1, 1, 0, height);
JOYX = ajx;
JOYY = ajy;
// av = v >= 0 ? v * v : -v * v; // From Quark on P Forum
cartX = map(stick.getSlider("Xaxis").getValue(), -1, 1, -90, 90);
cartY = map(stick.getSlider("Yaxis").getValue(), -1, 1, 90, -90);
}
public void readStick() {
// Make sure we have the latest position
getUserInput();
//shadows.add(new PVector(px, py, 40));
}