Skip to content

Instantly share code, notes, and snippets.

@armadillu
Last active August 29, 2015 14:14
Show Gist options
  • Save armadillu/e543fd4618fddc0ed3c4 to your computer and use it in GitHub Desktop.
Save armadillu/e543fd4618fddc0ed3c4 to your computer and use it in GitHub Desktop.
glfw joystick access
vector<string> joys;
for(int j = 0; j < 5; j++){
bool joyOK = glfwJoystickPresent(j);
if(joyOK){
int n;
const float *data = glfwGetJoystickAxes(j, &n);
string thisj = string(glfwGetJoystickName(j)) + "\n axes\n";
//axes
for(int i = 0; i < n; i++){
thisj += " a" + ofToString(i) + ": " + ofToString(data[i], 2) + "\n";
}
thisj += "\n buttons\n";
//buttons
int nBut;
const unsigned char * bData = glfwGetJoystickButtons(j, &nBut);
for(int i = 0; i < nBut; i++){
thisj += " b" + ofToString(i) + ": " + ofToString((int)bData[i]) + "\n";
}
joys.push_back(thisj);
}
for(int i = 0; i < joys.size(); i++){
ofDrawBitmapString(joys[i], 100 + 130 * i, 100 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment