Skip to content

Instantly share code, notes, and snippets.

@dlion
Created February 24, 2013 15:41
Show Gist options
  • Save dlion/5024264 to your computer and use it in GitHub Desktop.
Save dlion/5024264 to your computer and use it in GitHub Desktop.
Retrieve Joystick Information using plib libraries
#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