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.

DS development > Does touch screen pen down trigger an interrupt?

#152656 - jiversen - Wed Mar 19, 2008 2:31 am

Hi,

I would like the DS to generate an interrupt when the pen touches the touch screen. Can it? I've been reading everything I can find and don't have a definite answer.

The one thing that gave me a sense of the _possibility_ is the comment 'Not sure if the TSC [touch screen controller] /PENIRQ is actually triggering an IRQ on the NDS' found in the nocash gbatek document (nocash.emubase.de/gbatek.htm).

However, everything else seems like evidence against this possibility:
1) All the code I've examined (libnds, dslinux) just regularly polls REG_KEYXY (libnds), typically during Vblank or Vcount interrupt handler. [On the other hand, key interrupts aren't typically used for the other keys, even though they are available, so this doesn't prove anything].

2) I haven't found any reference to interrupt enable flags for any of the 'new' arm7-only accessible keys (e.g. X, Y). This leads one to think there may be no interrupt support for the pen either. But the hinge does give an interrupt...

I'm hoping someone may have direct knowledge that they are willing to share.

Thanks

John

PS. If you care, the reason for the request is an interest in achieving timing accuracy greater than 1/60 second in recording pen-down times.

PPS. This is my first post, so I'd like to also say I've been amazed by the wealth of information and individuals' dedication to the DS homebrew found in this forum and online and in code made freely available. I've learned tremendously from all of your efforts. It's so much fun. I humbly say Thank You!

#152662 - wintermute - Wed Mar 19, 2008 2:51 am

The hinge & the X/Y button interrupts are only available on the arm7.

Generally speaking the button interrupts shouldn't be used for input. I'd need to go check some test code but I seem to remember the button interrupts being a continuous thing rather than a one shot thing - i.e. if you enable an interrupt for button A being down then you'll cycle through that interrupt continuously while the button is down. It's been a while though so feel free to test - I definitely came to the conclusion that it was only useful for key combo reset or similar features.

As far as we've been able to determine so far, there's no access to the pen irq line from the arm7.

To get higher frequency pen down sampling just increase the rate it's polled. You could use a timer or use the ytrigger code to interrupt on several scanlines instead of just one.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#152665 - jiversen - Wed Mar 19, 2008 3:07 am

Good to know about the button IRQs. I'd seen some mention that they weren't good for user input, but you've suggested why.

The timer route it is!

Thanks.

#152692 - tepples - Wed Mar 19, 2008 7:47 pm

wintermute wrote:
Generally speaking the button interrupts shouldn't be used for input. I'd need to go check some test code but I seem to remember the button interrupts being a continuous thing rather than a one shot thing - i.e. if you enable an interrupt for button A being down then you'll cycle through that interrupt continuously while the button is down. It's been a while though so feel free to test - I definitely came to the conclusion that it was only useful for key combo reset or similar features.

I have not tested keypress interrupts on the Nintendo DS, but I do remember having run some tests on the Game Boy Advance:
  • GBA hardware would give one interrupt or several interrupts when the button is pressed, no interrupts while the button is held, and zero to a few when the button is released. I chalked up the multiple interrupts to contact bounce.
  • VisualBoyAdvance, an emulator, would inaccurately give one interrupt each frame.

So sampling only once, twice, or thrice a frame, as might be done in a music game or fighting game, has the side effect of debouncing the switch.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.