libnds: Early read of X Key input and memset issue.

Post Reply
Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

libnds: Early read of X Key input and memset issue.

Post by Sylus101 » Tue Jan 06, 2009 4:41 pm

Running this quick program displays the text shown without the key held. Tested in no$gba (text shows twice) and on hardware (text shows once). Same occurs with KEY_Y and KEY_TOUCH.

Code: Select all

#include <nds.h>
#include <stdio.h>

int main(void) {

consoleDemoInit();

	while(1){
	
		scanKeys();
	
		if(keysHeld() & KEY_X)
			iprintf("This shouldn't show up");
		
		swiWaitForVBlank();
	}

	return 0;
}
EDIT - I also ran across something else, usage of memset on lines 161 and 188 of background.c are:

Code: Select all

memset(&bgState[layer], sizeof(BgState), 0); //line 161
//and
memset(&bgState[layer + 4], sizeof(BgState), 0); //line 188
Should be:

Code: Select all

memset(&bgState[layer], 0, sizeof(BgState)); //line 161
//and
memset(&bgState[layer + 4], 0, sizeof(BgState)); //line 188
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

ambient_enigma
Posts: 7
Joined: Mon Oct 06, 2008 4:42 pm

Re: libnds: Early read of X Key input and memset issue.

Post by ambient_enigma » Wed Jan 14, 2009 1:58 pm

I had a similar problem that was solved by removing the following lines:

irqInit();
irqEnable(IRQ_VBLANK);

The problem went away after that. Hopefully that will help you, even though I
don't see those lines in your code.
You can see my original post under devkitARM on the index page in the post
"X,Y buttons and Touch Screen Unresponsive in New devkitARM"

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: libnds: Early read of X Key input and memset issue.

Post by Sylus101 » Wed Jan 14, 2009 4:43 pm

Yea, those lines aren't in there. It was posted on the main site when 1.3.1 came out that those lines would need to be removed as it's being done beforehand.

Still, it surely happens just with what I've got here... hoping someone can duplicate as well and verify.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

afireohno
Posts: 6
Joined: Thu Jan 01, 2009 9:37 pm

Re: libnds: Early read of X Key input and memset issue.

Post by afireohno » Sat Jan 17, 2009 7:04 pm

Sylus, I ran into the same problem and after a great deal of frustration and trying random solutions got something to work. I'm not sure why, and it is definitely far from an elegant solution.

Code: Select all

#include <nds.h>
#include <stdio.h>

int main() 
{		
	consoleDemoInit();	
	for (int i = 0; i <2; i++)
	{
		swiWaitForVBlank(); //wait 2 or more (tested up to 10)
	}
	
	int test = 0;
	while(1) {		
		scanKeys();		
		if(keysHeld() & KEY_X)
		{
			test = 1;
		}
		swiWaitForVBlank();
		consoleClear();		
		printf("test = %i",test);		
	}
	return 0;
}
Like I said I have no idea why, but it seems to work. Thoughts anyone?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests