Button press/release

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

Moderators: cheriff, TyRaNiD

Post Reply
Maca
Posts: 2
Joined: Mon Aug 27, 2007 4:12 am

Button press/release

Post by Maca »

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: Select all

while ( 1 )
{

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

  lastPad = pad;
}
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

I guess you can replace the "if (pad.Buttons != lastPad.Button)s" by
"if (!(lastpad.Buttons & PSP_CTRL_SQUARE))"
Maca
Posts: 2
Joined: Mon Aug 27, 2007 4:12 am

Post by Maca »

Holy shit, man, thanks a lot. !
Post Reply