Homebrew [WIP] ButtonSwap3DS - Remap buttons on your 3DS

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
Would anybody mind building a version with the four face buttons rotated clockwise? That is:
  • When you press A, console triggers B
  • When you press B, console triggers Y
  • When you press Y, console triggers X
  • When you press X, console triggers A
I'd very much appreciate this, thanks if anybody can offer assistance.
 
  • Like
Reactions: renhei

danger229

Well-Known Member
Newcomer
Joined
Mar 1, 2017
Messages
56
Trophies
0
Age
26
XP
1,357
Country
United States
Would anybody mind building a version with the four face buttons rotated clockwise? That is:
  • When you press A, console triggers B
  • When you press B, console triggers Y
  • When you press Y, console triggers X
  • When you press X, console triggers A
I'd very much appreciate this, thanks if anybody can offer assistance.

Here you go, this should work for you. complete with an ugly custom made banner and icon.
 

Attachments

  • Rotate Face Buttons.zip
    351.6 KB · Views: 408

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
@danger229 This has been fantastic to use, many thanks! Is there any chance you'd be willing to do the reverse, too? That would be:
  • When you press A, console triggers X
  • When you press B, console triggers A
  • When you press Y, console triggers B
  • When you press X, console triggers Y
With apologies for the repeated hassle.
 

renhei

Well-Known Member
Newcomer
Joined
Jun 21, 2016
Messages
64
Trophies
0
XP
282
Country
United States
Was hoping this would allow me to swap the physical buttons on the 2DS and have them be the way I want them, but it only seems to be temporary, and a hassle to have to start up every time. Perhaps one day this can be turned into a service that runs at boot?
 
Last edited by renhei,

danger229

Well-Known Member
Newcomer
Joined
Mar 1, 2017
Messages
56
Trophies
0
Age
26
XP
1,357
Country
United States
Is it possible to map the circle pad to the dpad? If yes, can anyone do it?
Thanks :)
It will probablly take me a few days to figure out how to build a version that does what you want, ill see what i can do.

@danger229 This has been fantastic to use, many thanks! Is there any chance you'd be willing to do the reverse, too? That would be:
  • When you press A, console triggers X
  • When you press B, console triggers A
  • When you press Y, console triggers B
  • When you press X, console triggers Y
With apologies for the repeated hassle.
attached is a version that goes counter clockwise
 

Attachments

  • CCFBR.zip
    346.9 KB · Views: 427

mcaboosec

Active Member
OP
Newcomer
Joined
Sep 15, 2009
Messages
34
Trophies
0
XP
408
Country
United States
Is it possible to map the circle pad to the dpad? If yes, can anyone do it?
Thanks :)
I actually made one to do it a couple days ago. Here it is! For those interested, here is the mapping:
Code:
ldr r3, =0x40
ldr r5, =0x7FF000
bl .cpad             
ldr r3, =0x80
ldr r5, =0x800000
bl .cpad             
ldr r3, =0x10
ldr r5, =0x0007FF
bl .cpad             
ldr r3, =0x20
ldr r5, =0x000800 
bl .cpad
The documentation had previously indicated that you should have bl .touch at the end of each mapping. It should have been bl .cpad.
 

Attachments

  • cpad.zip
    712.1 KB · Views: 497

danger229

Well-Known Member
Newcomer
Joined
Mar 1, 2017
Messages
56
Trophies
0
Age
26
XP
1,357
Country
United States
I actually made one to do it a couple days ago. Here it is! For those interested, here is the mapping:
Code:
ldr r3, =0x40
ldr r5, =0x7FF000
bl .cpad            
ldr r3, =0x80
ldr r5, =0x800000
bl .cpad            
ldr r3, =0x10
ldr r5, =0x0007FF
bl .cpad            
ldr r3, =0x20
ldr r5, =0x000800
bl .cpad
The documentation had previously indicated that you should have bl .touch at the end of each mapping. It should have been bl .cpad.
Ill take note of this if i do other things that need it. right now just kind of tinkering around as i am having a problem getting a version to run with NTR Mode 3 properly as it just kinda stops after swapping into NTR Mode 3.
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
attached is a version that goes counter clockwise
Thanks, danger229. I'm seeing some odd behavior with this one, though, button combinations seem to have the wrong results? When I press buttons individually, everything is fine, but if I press, e.g. A+B together, no buttons are registered (should be A+X) ... B+Y together registers Y+A (should be B+A), X+Y together registers X+B (should be Y+B), X+A together registers Y+A (should be Y+X), etc. Some kind of XOR mask issue or something?

EDIT: I bit the bullet and set up a build environment for myself, but I'm really not able to wrap my head about the button and XOR masks at all. I think if I just wanted to swap some buttons (e.g. A<->B) I'd be able to do it, but A->X->Y->B->A is a complete mystery to me. Would anyone be willing to post some actual code examples for how these sorts of things are done? I'm afraid the text-based documentation isn't enough for me to follow.

EDIT2: I guess my real issue is this portion of the instructions:
For a 1:1 button swap, the button masks and xor masks will be the same. For example, if you want to swap A with B, and vice versa, both the button and xor masks would be 0x3.

For a combo swap (e.g. L+B=R), this mask would require the L, B, and R fields to be active (a mask of 0x302), while the button mask would just be the L and R fields (a mask of 0x300).
My problem is that I'm not trying to do either of these (transposing two buttons or creating button combos). Rather, I'm trying to rotate multiple buttons, and that doesn't seem to be covered in the documentation.

EDIT3: For that matter, the last instruction there doesn't make any sense to me at all. If the button mask is supposed to be the buttons required to activate the remap, why would it be L+R? The combo is L+B to trigger R in that example, so shouldn't the button mask be L+B?

EDIT4: Just for reference, this is what I thought should work. It does literally nothing on the 3DS, though, and I have zero idea of where I'm going wrong.
Code:
ldr r3, =0x1
ldr r4, =0x401
bl .single
ldr r3, =0x2
ldr r4, =0x3
bl .single
ldr r3, =0x400
ldr r4, =0xC00
bl .single
ldr r3, =0x800
ldr r4, =0x802
bl .single
The values in r3 are the physical buttons pressed with the finger, "buttons [which] will activate the remapping", and the values in r4 are "the buttons that will be used to activate the remap, and the buttons you want activated by the remap." I'm completely lost as to how I'm not following the instructions as written, but I'm pretty clearly out of my depth.

EDIT5: And what the hell, for completeness, this is what I think the button values are, since I had to calculate them manually (no Java on this machine), I believe [incorrectly?] that these are the values:
Code:
     DEC   HEX
A =    1 =   1
B =    2 =   2
S =    4 =   4
S =    8 =   8
> =   16 =  10
< =   32 =  20
^ =   64 =  40
v =  128 =  80
R =  256 = 100
L =  512 = 200
X = 1024 = 400
Y = 2048 = 800
Would love any advice.
 
Last edited by Vague Rant,

mcaboosec

Active Member
OP
Newcomer
Joined
Sep 15, 2009
Messages
34
Trophies
0
XP
408
Country
United States
Ill take note of this if i do other things that need it. right now just kind of tinkering around as i am having a problem getting a version to run with NTR Mode 3 properly as it just kinda stops after swapping into NTR Mode 3.
Unfortunately, I don't know how much help I can offer for Mode 3 since I don't have an O3DS. If you have any success, let me know!

EDIT4: Just for reference, this is what I thought should work. It does literally nothing on the 3DS, though, and I have zero idea of where I'm going wrong.
ldr r3, =0x1
ldr r4, =0x401
bl .single
ldr r3, =0x2
ldr r4, =0x3
bl .single
ldr r3, =0x400
ldr r4, =0xC00
bl .single
ldr r3, =0x800
ldr r4, =0x802
bl .single
The values in r3 are the physical buttons pressed with the finger, "buttons [which] will activate the remapping", and the values in r4 are "the buttons that will be used to activate the remap, and the buttons you want activated by the remap." I'm completely lost as to how I'm not following the instructions as written, but I'm pretty clearly out of my depth.
For feeling out of your depth, you actually have a pretty good handle on things. This should be the correct mapping, and I also get no results when running it on my 3DS. I'll look into this more tomorrow. (While writing this post, I may have found the issue. I won't be able to test it until tomorrow)

And what the hell, for completeness, this is what I think the button values are, since I had to calculate them manually (no Java on this machine), I believe [incorrectly?] that these are the values:
These values are correct, but the hex form is more useful to us.

For a combo swap (e.g. L+B=R), this mask would require the L, B, and R fields to be active (a mask of 0x302), while the button mask would just be the L and R fields (a mask of 0x300).
For that matter, the last instruction there doesn't make any sense to me at all. If the button mask is supposed to be the buttons required to activate the remap, why would it be L+R? The combo is L+B to trigger R in that example, so shouldn't the button mask be L+B?
Um...wow, yeah. Thanks for catching that; I feel pretty stupid now. I'll update the original post.

I'm really not able to wrap my head about the button and XOR masks at all. [...] I'm trying to rotate multiple buttons, and that doesn't seem to be covered in the documentation.
I'll also review and revise the instructions to make sure it's a bit easier to understand. You're right that it's not covered in the current documentation; I guess it just made sense in my head what the documentation says.
For clarity right now though, 1:1 "swap" isn't the right terminology; it should be 1:1 map instead. What I meant by that is that one button would be mapped to another. This could be a swap where each button presses the other (e.g. A presses B, B presses A), or a map (e.g. A presses B, but B also presses B) depending on the masks. The button mask would be the button(s) that trigger it. In the case of an A/B swap, the button mask would indicate either can be pressed (0x3), and the XOR mask would indicate that both values should be switched (0x3 as well).

This is how it works: if you press A, your raw data would be 111111111110. We only care about 2 of these values in this case: A and B. We use our button mask to get the values we want. That mask is 0x3, or 11 in binary. We AND the raw data with 11, and we get our important values.
Code:
111111111110
&         11
------------
          10
Now we can see if the buttons we want were pressed. In the .single function, we do this by checking to see if our specific values (10) do not match our button mask (11). If they do match, it means neither button was pressed.
Our XOR mask is used to perform an xor function on this data when the button mask matches. The XOR operation can be thought of as one or the other, but not both. So, our xor mask is 11 in binary. When we apply that to our data, we get this:
Code:
  10
^ 11
----
  01
Since our B button was not pressed (the 1 in 10), we get the "not both" part of the XOR (0). Since A was pressed, we get "one or the other", resulting in 01 (B pressed, not A).

I hope this helps to clarify about how the masks are used. Let me know if I just made things more confusing.
 
Last edited by mcaboosec,
  • Like
Reactions: Vague Rant

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
Thanks very much, @mcaboosec, a really concise and readable explanation, even for a lay user like me. And I'm glad to see I wasn't quite as confused as I'd thought! ;) Don't underestimate the current documentation too much, though. I'm no kind of coder at all, me not understanding what's going on is a very low bar for it being good documentation; I'm not really the intended target for any technical documentation.

FYI, the same L+B=R example is used in the readme on GitHub.
 

Quantumcat

Dead and alive
Member
Joined
Nov 23, 2014
Messages
15,144
Trophies
0
Location
Canberra, Australia
Website
boot9strap.com
XP
11,094
Country
Australia
I just remembered an idea I had a long time ago that this program would be able to achieve.

I thought it would be cool to make the console left-handed. So, with a circle pad pro attached, the cpp stick would be the main analogue stick, and the D-pad would become the A, B, X, Y buttons as a mirror image. The A, B, X, Y buttons would become the D-pad. This was before the New 3DS was invented, but the nub on the N3DS is not really useable as a C pad so would only really be practical with a CPP.

This would make life a lot easier for left handers in any game that requires the stylus while playing. For example, Kid Icarus. (That might be the only example...)
 
  • Like
Reactions: Hayleia

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
I just remembered an idea I had a long time ago that this program would be able to achieve.

I thought it would be cool to make the console left-handed. So, with a circle pad pro attached, the cpp stick would be the main analogue stick, and the D-pad would become the A, B, X, Y buttons as a mirror image. The A, B, X, Y buttons would become the D-pad. This was before the New 3DS was invented, but the nub on the N3DS is not really useable as a C pad so would only really be practical with a CPP.

This would make life a lot easier for left handers in any game that requires the stylus while playing. For example, Kid Icarus. (That might be the only example...)
This isn't entirely possible currently as the extra buttons/stick aren't mappable with ButtonSwap3DS, but for a game like Kid Icarus where the right stick is already a duplicate of the left one, this is easy enough to do, so I quickly threw it together. Tested the standard version to confirm it does as expected, can't test the mode3 version as I don't have an original 3DS. All this does is swap the D-Pad and ABXY buttons.
 

Attachments

  • ButtonSwap3DS-DPadABXY.zip
    686.1 KB · Views: 350
  • Like
Reactions: Quantumcat

danger229

Well-Known Member
Newcomer
Joined
Mar 1, 2017
Messages
56
Trophies
0
Age
26
XP
1,357
Country
United States
@mcaboosec It seems that the Mode3 issue was mainly on my end since i was not building with the cia_mode3.rsf file, other than that only problem i have with node 3 stuff is that the 3ds sometimes encounters an error when going from the button swap app to the NTR_Node3 app. seems hit or miss if it crashes or not.
 

mcaboosec

Active Member
OP
Newcomer
Joined
Sep 15, 2009
Messages
34
Trophies
0
XP
408
Country
United States
I thought it would be cool to make the console left-handed.
Once I can get N3DS buttons working, I would think this should work since they run similarly to the CPP. I'll let you know once I have something so you can try it.

@Vague Rant, I figured out the problem. The .single function would check to see if all buttons in the current mapping were pressed. If so, it just skipped the mapping. This would be good in the case that you were just trying to swap buttons like A and B, but not so much in the case of just mapping one button to another. It would check to see if all buttons in the button mask were pressed, and since only one is in the map and it was pressed, it just skipped the mapping. I've renamed the functions from .single and .combo to .anyMap and .allMap. .anyMap is to be used when any button in the button mask is to be the trigger, and .allMap is to be used when all buttons in the mask must be pressed to activate the mapping. I've pushed these changes, so go ahead and pull the repo and try again.

@danger229, I'm glad you were able to get part of the issue sorted out. I'm initially inclined to say that the errors are due to Mode3 being somewhat newer, but there could be something else going on behind the scenes that could cause Mode3 ButtonSwap and Mode3 NTR to be incompatible.
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,463
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,290
Country
I've pushed these changes, so go ahead and pull the repo and try again.
Done, thanks for the rapid response! This works perfectly for single button maps, but as soon as I start pressing multiple remapped buttons things get a bit wonky, as I described with danger229's CIA earlier.

Using the following mapping ...
Code:
ldr r3, =0x1
ldr r4, =0x401
bl .allMap
ldr r3, =0x2
ldr r4, =0x3
bl .allMap
ldr r3, =0x400
ldr r4, =0xC00
bl .allMap
ldr r3, =0x800
ldr r4, =0x802
bl .allMap

... individual buttons work fine. Pressing B triggers A, A triggers X, and so on. But the results when pressing multiple buttons are less promising.
  • A+B triggers nothing
    should be X+A
  • B+Y triggers nothing
    should be A+B
  • A+X triggers A+Y
    should be X+Y
  • X+Y triggers B+X
    should be Y+B
  • A+Y triggers A+B
    should be X+B
  • B+X triggers B+Y
    should be A+Y
  • A+B+Y triggers A
    should be X+A+B
  • A+B+X triggers A+B+Y
    should be A+X+Y
  • A+X+Y triggers A+B+X
    should be X+Y+B
  • B+X+Y triggers X
    should be A+Y+B
  • A+B+X+Y triggers A+X
    should be X+Y+B+A
Sorry about the alphabet soup, I know that's kind of meaningless to look at. For the most part, this isn't all that bad, but you do start to run into problems when you're playing something that expects you to use button combos. For example, in Mario games where the buttons are B+A (such as NES Virtual Console games) and this layout remaps those to Y+B, you can't run (Y) and jump (B) at the same time (from the key above, Y+B triggers nothing). When you attempt a running jump, Mario stops doing both and reverts to walking speed (or potentially walks right into a bottomless pit). Sorry for not having better results. :(
 

rolim91

Member
Newcomer
Joined
Aug 11, 2007
Messages
10
Trophies
0
XP
250
Country
Canada
I checked the code, I am not sure if this is correct but using combo with .all map does not work.

A+B = Select

A+B pressed and Select not pressed
100 XOR 111 = 011 (Works)​
A+B+Select Pressed
000 XOR 111 = 111 (Nothing is pressed)​
A+Select pressed and B not pressed
010 XOR 111 = 101 (B is pressed)​
B+Select pressed and A not pressed
001 XOR 111 = 110 (A is pressed)​
 
Last edited by rolim91,

mcaboosec

Active Member
OP
Newcomer
Joined
Sep 15, 2009
Messages
34
Trophies
0
XP
408
Country
United States
But the results when pressing multiple buttons are less promising.
  • A+B triggers nothing
    should be X+A
  • B+Y triggers nothing
    should be A+B
  • A+X triggers A+Y
    should be X+Y
  • X+Y triggers B+X
    should be Y+B
  • A+Y triggers A+B
    should be X+B
  • B+X triggers B+Y
    should be A+Y
  • A+B+Y triggers A
    should be X+A+B
  • A+B+X triggers A+B+Y
    should be A+X+Y
  • A+X+Y triggers A+B+X
    should be X+Y+B
  • B+X+Y triggers X
    should be A+Y+B
  • A+B+X+Y triggers A+X
    should be X+Y+B+A
That is actually really good information. I'll look into it further; this is really strange behavior.
I checked the code, I am not sure if this is correct but using combo with .all map does not work.

A+B = Select

A+B pressed and Select not pressed
100 XOR 111 = 011 (Works)​
A+B+Select Pressed
000 XOR 111 = 111 (Nothing is pressed)​
A+Select pressed and B not pressed
010 XOR 111 = 101 (B is pressed)​
B+Select pressed and A not pressed
001 XOR 111 = 110 (A is pressed)​
What is your button mask and are you using .allMap or .anyMap? The second example (A+B+Select) makes sense, since A+B is triggering the remap and un-pressing Select. I'll have to see if there is a way to prevent it though.

I'm thinking both these issues may be the same underlying bug. I really appreciate the feedback and testing, thanks!
 
Last edited by mcaboosec,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    LeoTCK @ LeoTCK: yes for nearly a month i was officially a wanted fugitive, until yesterday when it ended