Hello Mark,
Just a stupid remark:
They say in the SDL wiki that SDL_InitSubSystem must be called after
SDL_Init():
http://www.libsdl.org/cgi/docwiki.cgi/SDL_InitSubSystem
I don’t see any call to SDL_Init() in your code. Check out if it changes something …
Julien.
----- Message d’origine ----De : Mark
? : sdl at libsdl.org
Envoy? le : Vendredi, 18 Juillet 2008, 15h33mn 07s
Objet : [SDL] New user, question about joystick.
Newbie here, trying to make my joystick work in a simple console application.
I can’t get out my axis values, it just repeats 0.0000. Any thoughts? Do I need
to check for events?
It goes into a loop I know…
#include <stdlib.h>
#include <SDL.h>
int main(int argc, char *argv[])
{
SDL_Joystick *joy;
// Initialize the joystick subsystem
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
// Check for joystick
if(SDL_NumJoysticks()>0){
// Open joystick
joy=SDL_JoystickOpen(0);
if(joy)
{
printf(“Opened Joystick 0\n”);
printf(“Name: %s\n”, SDL_JoystickName(0));
printf(“Number of Axes: %d\n”, SDL_JoystickNumAxes(joy));
printf(“Number of Buttons: %d\n”, SDL_JoystickNumButtons(joy));
printf(“Number of Balls: %d\n”, SDL_JoystickNumBalls(joy));
}
else
printf(“Couldn’t open Joystick 0\n”);
int SDL_JoystickEventState(true);
while(1) {
printf("%f",SDL_JoystickGetAxis(joy, 0));
}
return 0;
}
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr