The starfox one was archived
https://web.archive.org/web/20110604163902/http://crackerscrap.com/docs/sfchacktut.html
GBAtek is now located
http://problemkaputt.de/gbatek.htm
The stuff I wrote above is pretty much what I would say today.
The GBAtek link shows the (read only) bit of memory which the system changes when buttons are pressed. For the reasons mentioned in the first post then sensible game coders will copy this state every vblank usually (maybe hblank for something really strange or it could be some other set period or prior to a certain operation in some cases) to somewhere in memory. Anything that depends upon the button press will likely then read that area of memory.
You then get to figure out what the game reads from that area and does in response. Three main approaches game devs will use
1) All hard coded right down to the assembly level
2) Control mapping setups
3) Full remapping.
At a code level 2) and 3) will probably look fairly similar but where you might need to go full bore assembly hack you might be able to find a sort of table in the game somewhere to change what it calls a given setup.
1) will probably look something like
[read control state into memory/register]
either compare or do some boolean operation and then compare to find if the button you want is pressed
if pressed call jump/shoot/start game/glug potion/whatever routine
else carry on with life
You then get to alter this compare to read the results of another button. In the case of the DS it might be slightly more complex if you want to read the X and Y buttons as they are DS special registers and not GBA buttons which are A and B. Chances are the devs will do it all in one lump and it will probably not be anything drastic but be aware of that.
Quote from gbatek
4000136h - NDS7 - EXTKEYIN - Key X/Y Input (R)
0 Button X (0=Pressed, 1=Released)
1 Button Y (0=Pressed, 1=Released)
To this end if you wanted to read the result of Y rather than X you would want to get the function to look at bit 1 rather than bit 0 by altering whatever means it uses (could be many things but will be fairly obvious).
The cowboy method is also an option but will probably be game wide where the above is more precise. If you don't care then great, it is also useful if you have many functions all looking at one button and you want to change them all without hunting down each individual one.
I mentioned it copying to memory. After it has copied to memory then you jump in and swap whatever bits or disable whatever bit you want (some people like this if their shoulder buttons fail and look as though they are constantly pressed). Or to go back to the case above and say swap X and Y then you would want to figure out if either was pressed, store that and that alone in a number that represents the other, set both to be low and then probably do a logical OR with the results of that to swap buttons.