GP2X Button Presses


andrew_j_w

Still Fresh
Joined
Sep 18, 2005
Messages
59
Hi all,

Which register stores the button presses (A,B,X,Z,Start,Select,Triggers)? I'm reading 0x1184 which I think should have them, but nothing changes.

0x1186 gives me the volume up and volume down buttons, and 0x1198 registers the joystick fine but I just can't find the rest of the buttons.

Can anyone help?

Cheers,
Andrew
 
I have already tried using the minimal library, and what is really confusing is that it doesn't register those button presses either! Only the joystick and volume up and down are detected, nothing else.

This is with both 0.A and 0.B.

Those buttons do work in both the menu and DrMD though, which means my GP2x isn't broken...

Andrew

EDIT:

This is the compiler I'm using, in case people think that will make a difference.

Code:
andrew ~ # arm-unknown-linux-gnu-gcc --version
arm-unknown-linux-gnu-gcc (GCC) 4.0.3 (Gentoo 4.0.3, pie-8.7.8)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
here's what I am using.

Code:
enum e_buttons {
BUT_START=8, BUT_SELECT, BUT_L, BUT_R, BUT_A, BUT_B, BUT_X, BUT_Y,
VOL_DN=6+16, VOL_UP, JOY_PRESS=11+16,
JOY_UP=0+160, JOY_UL, JOY_LT, JOY_DL, JOY_DN, JOY_DR, JOY_RT, JOY_UR
};

int IsButtonPushed(int Button)
{
  return !(g_pusRegs[(0x1184>>1)+Button/16] & (1<<(Button&0xF)));
}
 
Thanks for the replies guys. Oddly the the GPIO test program that is linked from that article, Squidge, doesn't work.

It reads the vertical/horizontal sync ok but no matter what button I press the registers stay the same. It detects the joystick and volume up/down buttons ok.

This, combined with the problems I've had with the minimal library, lead me to believe there is a problem with my compiler. Compiling code that is known to work, but doesn't is horribly confusing. It doesn't crash though, it appears to runs fine.

Andrew
 
Jackpot! It was my compiler, not my code that was the problem. If I compile everything with -mcpu=arm920t then it works flawlessly.

Thanks for your help everyone, hopefully next time I'm back it'll either be with an actual problem, or something to announce :)

Andrew
 
Possibly your compiler was optimizing out the actual reads (or reading once and caching the result). I think there's a way to make things like that atomic, but I don't know offhand.
 
Back
Top