Last active
August 29, 2015 14:14
-
-
Save armadillu/e543fd4618fddc0ed3c4 to your computer and use it in GitHub Desktop.
glfw joystick access
This file contains hidden or 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
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