Paddle management

vbt

Staff member
Actually I use this on all dev i did :


if(( device = PER_GetDeviceR( &__port[0], 0 )) != NULL )

{

pltriggerE[0] = pltrigger[0];

pltrigger[0] = PER_GetTrigger( device );

pltriggerE[0] = (pltrigger[0]) ^ (pltriggerE[0]);

pltriggerE[0] = (pltrigger[0]) & (pltriggerE[0]);


for(i=0;i<11;i++)

{

if((pltrigger[0] & pad_asign)!=0)

{

switch(pltrigger[0] & pad_asign )

{

case PER_DGT_U:

temp &= ~0x01;

break;


case PER_DGT_D:

temp &= ~0x02;

break;


case PER_DGT_L:

temp &= ~0x04;

break;



But it gives some problems when you have to handle a single push. Is there something to do to change that behavior ? The main target is to add/fix Pause button, game selection in SMS plus and also on other things I did.
 
I remember running into a similar problem in my Snakes clone. I handled pause like this:

Code:
// Displays the text "Press Start" and waits for the user to hit start

void pressStart()

{

   Uint16 start;

   do{

        start = Smpc_Peripheral[0].data; // Checks if start button has been pressed

        slPrint("Press Start", slLocate(15, 23));

        slSynch();

        slSynch();

        slSynch();

    }while((start & pad_asign[7])!= 0);

}
 
Thanks Slinga and good to see you back :) I'll try your solution at then end of the week (i'll be on holidays).
 
vbt said:
But it gives some problems when you have to handle a single push. Is there something to do to change that behavior ? The main target is to add/fix Pause button, game selection in SMS plus and also on other things I did.

To detect the push of a button, you'll have to detect the transition from not pressed to pressed. The SGL already keeps track of that information on it's own.

The problem you might ran into (in a frame-by-frame approach) is that one button press of the user might result in a couple of pressed/not pressed states in successive frames. Might be a physical or mechanical issue of the pad's button. Anyways, to detect a push, you'll have to record the button state of the previous frame, at least. What I suggest to overcome the above mentioned problem is, to record the button state of multiple frames instead.

For example after a push, when the button state is "released" in the last 3 frames, then you can be shure that this push is really over.
 
RockinB said:
For example after a push, when the button state is "released" in the last 3 frames, then you can be shure that this push is really over.


Nice I'll test this method also, it can be usefull in all my "bad" devs.


I've just found also in the doc (I rarely check it :thumpdown:) :


* PER_GetEdge()


Get the trigger information that changed between two

specified timings.


* PER_GetPressEdge()


Get the trigger press information between two specified timings.


* PER_GetReleaseEdge()


Get the trigger release information between two specified

timings.


I have no idea if it's worth to use them or it can affect speed.
 
Back
Top