Archived

This topic is now archived and is closed to further replies.

Origin2052

SDL Questions. Please help!

Recommended Posts

Joysticks:

SDL_Joystick *InitJoy()
{
int nb_joy;
SDL_Joystick *joy;

nb_joy = SDL_NumJoysticks(); // return the number of joysticks available
if(nb_joy > 0)
joy = SDL_JoystickOpen(0); // open first joystick
if(!joy)
{
printf("Error: unable to open joystick");
return NULL
}
SDL_JoystickEventState(SDL_ENABLE); // enable joystick to send events

return joy;
}


if want to know more, go to the sdl website in the section Doc Project

Matt

[edited by - lemurion on October 11, 2003 3:08:27 PM]

Share this post


Link to post
Share on other sites
I Don''t know about gamepads but I suggest using SDL_mixer for sound in SDL apps. It handles all the mixing so you don;t have to.

http://jcatki.no-ip.org/SDL_mixer/SDL_mixer.html

Share this post


Link to post
Share on other sites
http://www.libsdl.org

Should have enough information for what you''re looking for.

~~~ Signature: ~~
"Satan sent me to destroy the video game industry." - Trigger(my alter ego)
"God is a game designer too and his game, ''Life'' " - Me
"Squirrles make me horny." - Sean Randy Rowlen Uranus

Share this post


Link to post
Share on other sites
I''ve looked at the sdl site but their "help" is too complex for me.. I don''t get it.

Could someone post an example? Oh and about gamepads, thanx lemurion that''s great! But what about actually detecting if someone is pressing a button on the gamepad? How do I do that?

Share this post


Link to post
Share on other sites
And what about gamepads that support rumble and force feedback? How would you get the gamepad to shake using SDL?





--{You fight like a dairy farmer!}

Share this post


Link to post
Share on other sites
As mentioned in the documentation, force feedback is not yet supporte. Perhaps it will be in SDL 2.0 . The docs also have many code snippets that help you understand the API.

Share this post


Link to post
Share on other sites