Created
February 24, 2013 15:41
-
-
Save dlion/5024264 to your computer and use it in GitHub Desktop.
Retrieve Joystick Information using plib libraries
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
#include <plib/js.h> | |
int main() | |
{ | |
jsJoystick *js[1]; | |
float *assi[1]; | |
int j; | |
jsInit(); | |
js[0]= new jsJoystick(0); | |
if(!js[0]->notWorking()) | |
{ | |
printf("Joystick's name found: %s\n",js[0]->getName()); | |
assi[0] = new float[js[0]->getNumAxes()]; | |
while(!js[0]->notWorking()) | |
{ | |
int dato; | |
js[0]->read(&dato,assi[0]); | |
printf("Button: %x\n",dato); | |
for(j=0; j < js[0]->getNumAxes(); j++) | |
printf("%+.1f ",assi[0][j]); | |
putchar('\n'); | |
fflush(stdout); | |
usleep(10000); | |
} | |
} | |
else | |
puts("Joystick not found"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment