Path: chuka.playstation.co.uk!scea!peter_alau@playstation.sony.com From: Elliott Lee Newsgroups: scea.yaroze.programming.2d_graphics,scee.yaroze.freetalk.english Subject: Re: Controlling the PAD... Date: Thu, 20 Aug 1998 15:35:35 -0700 Organization: Cisco Systems Lines: 138 Message-ID: <35DCA4B7.23251261@jps.net> References: <6rgb76$g19@scea> <6rgmt1$l2e20@chuka.playstation.co.uk> Reply-To: tenchi@jps.net NNTP-Posting-Host: dhcp-m-62-238.cisco.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.03 [en] (Win95; U) Xref: chuka.playstation.co.uk scea.yaroze.programming.2d_graphics:407 scee.yaroze.freetalk.english:1865 That would work, although you need to have a flag to note that the down direction was released. The reason is that it would appear you are using the PadStatus buffer and masking it for the PADdown bit. Thus, your code will initiate the timer on the first frame that Down is pressed and then the next frame the down direction will still be pressed so it will fall through to the else condition. It may be more efficient to set up a general queue of events which tracks the last 16 or so pad direction presses. That way you could know when the down was first pressed then released and check to see if a second down/release occurred so many frames afterward. This could also extend to fighting games where you would want to track the combos of your character. For instance, the following (without regard to timing) could provide you with the history of pad directional presses for the past 16 pad events. To check to see if the down was pressed twice, then you could check to see if currently the down direction bit is set and that somewhere in the history the down was released once and pressed at least once before that. If you wanted to check to see if someone did a fireball motion (down, down-right, right), you could walk back up the queue checking the down and right bits to see if they were set in that order. Etc. etc... ============================================================ #define PAD_EVENT_LEN 16 #define PAD_EVENT_MASK (PADdown|PADup|PADleft|PADright) u_long PadStatusQ[PAD_EVENT_LEN],PadStatusLast; #........................................... # Call when you need to init void InitPadQ( void ) { int p; for( p=0; p > Steve Tolin wrote in message <6rgb76$g19@scea>... > >I don't know if anyone has asked this yet.... > > > >How would you register a double tap on the d-pad??? > > > >Let's say holding down on pad makes character duck > > if (PadStatus&PADdown) > > { > >// printf("You just pressed the D-PAD: DOWN\n"); > > AnimateDucking(); > > } > > > > > >What would have to go in here??? > > > > if (PadStatus&*******************) > > { > >// printf("You just pressed the D-PAD: DOWN\n"); > > AnimateCrouch(); > > } > > I think the only way you would be able to do this is by having a > timer - > i.e. > > static short iTimer=0; > static short iLast=-1; > > if( PadStatus&PADdown) > { > printf("You just pressed the D-PAD: DOWN\n"); > if( iLast == -1 ) > { > iLast = iTimer; > printf("First press\n"); > } > else > { > // take it that we want it to be pressed twice within 5 updates > // you will have to alter this according to how fast you need to do > // the double press > if( iTimer - iLast < 5 ) > { > AnimateCrouch(); > iTimer = 0; > iLast = -1; > } > } > } > > if( iLast != -1 ) iTimer++; > > This should help. If not just drop me an email > > D. > -- > dave@ulthwe.demon.co.uk > ICQ: 244386 -- Mata ne, ... ... - e! ::' tenchi@shell.jps.net ':: (Protocol) :: ACiD -/- ACS -/- pHluid -/- Yaroze -/- Nemesis :: (Tenchikun) ::. http://www.jps.net/tenchi .:: ''' '''