gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Depress key interrupt.

#21552 - mr_schmoe - Mon May 31, 2004 9:12 pm

Can the GBA be set up to fire an interrupt when the player depresses and interrupt?

I've been trying to learn how to setup the keyboard interrupt, but I've noticed something. My keyboard handler routine doesn't get called when I depress a key, only when I press a key. Does that mean, I can't do what I'm talking about?
_________________
How many boards could the Mongols hoard, if the Mongol Hored got bored

#21554 - bats - Mon May 31, 2004 9:34 pm

Depress means the same thing as press.
And no, the interrupt does not fire when you release a key.

Ben

#21556 - mr_schmoe - Mon May 31, 2004 10:48 pm

Quote:
Depress means the same thing as press.

I new that. ;)
_________________
How many boards could the Mongols hoard, if the Mongol Hored got bored

#21558 - Akolade - Mon May 31, 2004 11:27 pm

Doesn't depress mean release?? Yes, I believe it does.

#21561 - keldon - Mon May 31, 2004 11:38 pm

actually means a bit of both :)

#21575 - isildur - Tue Jun 01, 2004 3:20 am

Depressing keys need Prozac.
:)

#21650 - tepples - Wed Jun 02, 2004 5:44 pm

The GBA does not have a known key-release interrupt. I'll need more information about how you plan to use this interrupt in order to tailor a workaround to your needs.

If you just need an interrupt to happen when the player releases a given button, such as if you want to save power, you might try polling the buttons in a vblank ISR.

If you want to know with sub-frame precision when the player released the button, then try setting a few vcount interrupts (that is, change the vcount trigger scanline at the end of each vcount ISR) and polling the buttons then, or poll them in an hblank ISR.

Or do you need something else?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#21652 - tepples - Wed Jun 02, 2004 6:38 pm

Dupe
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#21656 - expos1994 - Wed Jun 02, 2004 6:54 pm

Here's how I'd try to handle this...

Code:

if (THE BUTTON IS PRESSED)   
     key_pressed = 1;  //you pressed it
else if (key_pressed == 1) //if you previously had it pressed...
{
     key_depressed = 1; //...then you depressed it.
     key_pressed = 0;
}

.
.
.

if (key_depressed == 1)
{
        <<your depressing code here.  I'm depressed just thinking about   what you would put here.>>
        .
        .
        . 
        key_depressed = 0;
}


=============================

That makes sense to me... It should pick up if you pressed a button and then depressed it.

Hope that works for you.
---Chris

#21660 - isildur - Wed Jun 02, 2004 7:11 pm

Yeah this is how I do it:
Code:

if((gba_readpad() & PAD_UP) == 0)
{
   padUpPressed = 1; // set flag
   // do pad pressed stuff
}
else
{
   // pad is no pressed
   
   if(padUpPressed) // if true, then we know it just has been released
   {
      // pad has been released
      // do pad released stuff
      padUpPressed = 0; // reset flag
   }
}

#21669 - sajiimori - Wed Jun 02, 2004 8:17 pm

This is the English police. Please stop using the word 'depress' when you mean 'release'. Thank you for your cooperation.

=)