forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Button press/release

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Maca



Joined: 27 Aug 2007
Posts: 2

PostPosted: Mon Aug 27, 2007 4:17 am    Post subject: Button press/release Reply with quote

I'm trying to implement semi-automatic gunfire for my game.
With this code here. If I press square, the gun sound will play and if I release square it will play again
when I press square again, which is what I want.
But if while I'm holding square and then press any other button, the wav will play, and then again when I release that button. I need to find a way to stop it from playing when I press/release the other buttons while holding square?

Code:

while ( 1 )
{

  sceCtrlReadBufferPositive( &pad, 1 );
   
  if ( pad.Buttons & PSP_CTRL_SQUARE  )
  {
      if( pad.Buttons != lastPad.Buttons )
      {
          WAV_Play(ourWav);
      }
  }

  lastPad = pad;
}
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Mon Aug 27, 2007 5:03 am    Post subject: Reply with quote

I guess you can replace the "if (pad.Buttons != lastPad.Button)s" by
"if (!(lastpad.Buttons & PSP_CTRL_SQUARE))"
Back to top
View user's profile Send private message
Maca



Joined: 27 Aug 2007
Posts: 2

PostPosted: Mon Aug 27, 2007 5:09 am    Post subject: Reply with quote

Holy shit, man, thanks a lot. !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group