SDL input question

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
MadButch
Posts: 16
Joined: Sat Aug 20, 2005 7:11 pm

SDL input question

Post by MadButch »

Hello, I have a little problem getting the input working.
I made defines in my code, which use the numbers provided by the readme.psp file.

In my main loop, I have the following code to check for Up (6), Down (8) and X (2):

Code: Select all

while( SDL_PollEvent(&theSDLEvent) )
{
	if( theSDLEvent.type == SDL_QUIT )
	{
		bContinue		= false;
	}
	else if( theSDLEvent.type == SDL_JOYBUTTONDOWN )
	{
		if( theSDLEvent.type == PSP_CTRL_UP )
		{
			theSDLGraphics.SetActiveItem( theSDLGraphics.GetActiveItem() - 1 );
		}
		else if( theSDLEvent.type == PSP_CTRL_DOWN )
		{
			theSDLGraphics.SetActiveItem( theSDLGraphics.GetActiveItem() + 1 );
		}
		else if( theSDLEvent.type == PSP_CTRL_CROSS )
		{
			Mix_PlayChannel(0, mixSounds[0], -1);
			if( theSDLGraphics.GetActiveItem() == 3 )
			{
				bContinue	= false;
			}
		}
	}
}
I know this is not perfect yet, as I should also catch the SDL_JOYBUTTONDOWN message, but it should do something...

Unfortunately, it doesn't do anything :(

Does anyone see what I'm doing wrong?
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

The current button maps to theSDLEvent.jbutton.button.

See http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API for more information on SDL events.
MadButch
Posts: 16
Joined: Sat Aug 20, 2005 7:11 pm

Post by MadButch »

Thanks a ton... hehe... It's always the dummy things you overlook :)
I examined the vectoroids example some more, and noticed I was also missing initialisations and the JoystickOpen command.

Everything works like a charm now.

Next step: sound and music.
And then I'm ready to start coding...
Post Reply