Created
May 6, 2015 20:52
-
-
Save pvazteixeira/4cd48ba218febd9f0c6d to your computer and use it in GitHub Desktop.
read_hotas.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import procontroll.*; | |
import java.io.*; | |
ControllIO controll; // the base class that handles all devices | |
ControllDevice hotas; // the joystick object | |
ControllStick stick; // hotas stick | |
ControllStick throttle; // hotas throttle | |
ControllButton button; | |
float bg = 255; | |
void setup() { | |
size(400,400); | |
controll = ControllIO.getInstance(this); | |
// configure/initialize the device | |
hotas = controll.getDevice("T.Flight Hotas X"); | |
println(hotas.getName()+ " has "+hotas.getNumberOfButtons()+" buttons, "+hotas.getNumberOfSliders()+" sliders and "+hotas.getNumberOfSticks()+" sticks."); | |
hotas.printSliders(); | |
hotas.setTolerance(0.05f); | |
// configure the main stick | |
ControllSlider sliderX = hotas.getSlider("X Axis"); | |
ControllSlider sliderY = hotas.getSlider("Y Axis"); | |
stick = new ControllStick(sliderX, sliderY); | |
// configure the throttle stick | |
sliderX = hotas.getSlider("Slider"); | |
sliderY = hotas.getSlider("Z Axis"); | |
throttle = new ControllStick(sliderX, sliderY); | |
// configure buttons | |
button = hotas.getButton("Button 3"); | |
} | |
void draw() { | |
background(bg); | |
if(button.pressed()) { | |
bg = 127; | |
} | |
else { | |
bg = 255; | |
} | |
float m = 200; // multiplier: getx and gety output values between -1 and 1 | |
fill(255,0,0); | |
ellipse(m*stick.getX()+width/2, m*stick.getY()+height/2, 20, 20); | |
fill(0,0,255); | |
ellipse(m*throttle.getX()+width/2, m*throttle.getY()+height/2, 20, 20); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment