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

SorkOs

Member
Newcomer
Joined
Mar 4, 2019
Messages
6
Trophies
0
Age
34
XP
87
Country
Russia
@SorkOs In this mapping, pressing R makes your 3DS think you've pressed A and B. If that's not what you wanted, just tell me and I'll do the other way around!
Oy, yes, i need around, thanks! :)

--------------------- MERGED ---------------------------

And, maybe you write a guide to create remap files? I know quite a bit programming, but FAQ and OP-post very confused.
(Sorry for my english)
 

AmberLoss

Member
Newcomer
Joined
Jun 28, 2018
Messages
20
Trophies
0
Age
29
XP
106
Country
Brazil
@SorkOs Here you go! As for the guide, it's pretty simple: go to source/injected.s and insert your mapping under either the buttons part, the touchscreen part (for mappings involving the touchscreen) or the c-pad part (for mappings involving the c-pad). There are examples in the file, the first value is the button you'll phisically press and the second value is the button your 3DS will think you've pressed. You get the values from the ButtonSwap3DSHelper.jar. So for example, your swapping looks like this:

upload_2019-3-7_15-49-29.png


I do plan to make a proper guide, but I was planning to include it in the guide for setting up the build environment, and I need a blank slate for that, which I don't have yet. But I'm working on it!
 

Attachments

  • SorkOs-2nd.zip
    697.1 KB · Views: 200

SorkOs

Member
Newcomer
Joined
Mar 4, 2019
Messages
6
Trophies
0
Age
34
XP
87
Country
Russia
@SorkOs Here you go! As for the guide, it's pretty simple: go to source/injected.s and insert your mapping under either the buttons part, the touchscreen part (for mappings involving the touchscreen) or the c-pad part (for mappings involving the c-pad). There are examples in the file, the first value is the button you'll phisically press and the second value is the button your 3DS will think you've pressed. You get the values from the ButtonSwap3DSHelper.jar. So for example, your swapping looks like this:

View attachment 160236

I do plan to make a proper guide, but I was planning to include it in the guide for setting up the build environment, and I need a blank slate for that, which I don't have yet. But I'm working on it!

I understand how to create indected.s, but i do not understand how to compile it in cia.

Thank you very much for file!
 

AmberLoss

Member
Newcomer
Joined
Jun 28, 2018
Messages
20
Trophies
0
Age
29
XP
106
Country
Brazil
I understand how to create indected.s, but i do not understand how to compile it in cia.

Thank you very much for file!

I already explained in the FAQ that I plan to make a guide to set up the environment state but can't right now. The most common issue with setting it up is that OP doesn't mention it, but you also need buildtools. If your environment is set up, cd to the directory your mapping is in and run make.
 

NeoUmbreon

Active Member
Newcomer
Joined
Sep 22, 2016
Messages
29
Trophies
0
XP
196
Country
United States
Hello, i've determined 6 different mappings i'd like to request, if that's okay and not too many, or if these mappings are even possible, which i sure hope so, as especially for the first two it's been done before, only a bit differently for Team-Embrace. Thanks!

1: R > L+R+START
2: START > L+R+START
3: R > A+B+START+SELECT
4: START > A+B+START+SELECT
5: SELECT <> Y | START <> X | R > A+B+X+Y
6: SELECT <> Y | START <> X | START > A+B+X+Y

EDIT: Disregard all of this, I can do it myself thanks to Amber's build environment tutorial.
 
Last edited by NeoUmbreon,

KawaiiAurora

Member
Newcomer
Joined
Sep 26, 2016
Messages
5
Trophies
0
XP
56
Country
Italy
I recently acquired a 3DS whose touchscreen is defective but it still partially works. The vertical coordinate (y-value) works as intended but the horizontal coordinate (x-value) doesn't (when you tap on the far right, it marks in the middle and then moves horizontally as you go the left)

I want to map different x values to the segments that work thus allowing me to use the whole touchscreen albeit with reduced accuracy. An example of what I want to achieve is this:

When the digitiser marks COORD(50,30), I want it to register that as a press to COORD(150,30) by using a multiplier of x3.

I have been able to map buttons to points on the touchscreen with the following code:
ldr r4, =0x2
ldr r6, =0x1202282
bl .touch
However, I wasn't successful in mapping points on the touchscreen to other points. I tried this code:
ldr r4, =0x1202282; COORD(50,30)
ldr r6, =0x1202786; COORD(150,30)
bl .touch

Can someone tell me whether what I'm doing is possible with this utility? If so, how can I do it?


I know a bit of ASM so perhaps, someone could point me in the right direction if I have to modify the touch function :)

Thanks,
Aurora
 

SkyAngel

New Member
Newbie
Joined
May 15, 2018
Messages
1
Trophies
0
XP
77
Country
Dominican Republic
Thanks for this man! I've been googling and you are the only one working on this. The only thing I can see is that it doesn't work with the GBA Games, any future plans for that? I have a faulty A button that I need to press hard for it to work.
 

AmberLoss

Member
Newcomer
Joined
Jun 28, 2018
Messages
20
Trophies
0
Age
29
XP
106
Country
Brazil
Alright, I finally got the chance to use someone else's computer so I could have a blank slate to make a tutorial for setting up the building environment, so... here it is! I've also proposed it as a change to the README.md, hopefully it gets merged, but for now I'm posting it here too.

Also, I'm really sorry for disappearing, GBAtemp sometimes forgets I saw the last notification and stops notifying me of new posts. I'll make the mappings as soon as I get home! Which could take a few days.

@KawaiiAurora, I don't know if it is possible, but the reason it's not working is probably because (50,30) is a very specific coordinate, so you probably aren't even able to touch it. You'd have to map every single coordinate for it to work, or at least every coordinate in an area to test it. So like, (50,30), (51,30), (52,30), and so on... Then (50,31), (51,31), (52, 31)... You definitely could write a program (maybe even regex) to write all these mappings for you, but that's, like, 28.800 mappings, and I have no idea if that sheer amount is supported by ButtonSwap3DS (I think the largest amount tested to date has been around 15). And you'd still be out half a screen, if I understood your problem well (if I didn't, that's 57.600 mappings we're talking about). You could try it anyway, but replacing the touchscreen sounds easier and safer.

@SkyAngel, all developers have disappeared over a year ago, so there are no plans at all for anything, sorry!

Anyway, here's the tutorial for setting up the build environment and making mappings (sorry, no video):
Setting up the build environment
You will need a working setup of the devkitARM toolchain for 3DS, follow this guide for help.

Download makerom

Download bannertool

Put the makerom and bannertool files compatible with your OS on the devkitPro/devkitARM/bin folder. You can also leave them in the ButtonSwap3DS folder if it doesn’t work.

Clone ScenicRoute (or download the zip and extract it)

Clone ButtonSwap3DS (or download the zip and extract it)

Open msys (in Windows) or the command prompt (any OS)

(First of all, to “run” something means typing it on a terminal and pressing enter)

Navigate to your ScenicRoute folder (if you’re using Windows and saved it to [Your Username]/ScenicRoute, you’d run the command: cd ~/ScenicRoute. If you’re not using Windows, you probably know how to use cd)

Run make install

Navigate to your ButtonSwap3DS folder (if you’re using Windows and saved it to [Your Username]/ButtonSwap3DS, you’d run the command: cd ~/ButtonSwap3DS)

Go to the “How to Use” section if you haven’t done your mapping yet.

When your mapping is ready, run make.



The text you get after running make install will be different, but should be a success.

If you get the following error: [EXHEADER ERROR] Invalid FileSystemAccess Name: "SeedDB", remove the lines with SeedDB from the files cia.rsf and cia_mode3.rsf (from the ButtonSwap3DS/meta folder)

Important: whenever you get an error, you might need to close msys and make a new, fresh ButtonSwap3DS folder with only the things you got from cloning. That’s because, while trying to make your cia, some files get made that might have the mistake in them. (That’s 100% definitely the case if you get the SeedDB error)

How to Use
(Alternative: use danger229’s ButtonSwap3DSMaker instead of following the next steps)

For the mappings, edit the injected.s file. If your mapping only contains buttons, write it under the buttons section. If it involves the C-Pad (currently buttons can act as the C-Pad, but the C-Pad can’t be made to act as anything else), write it under the C-Pad section, and if it involves the touchscreen, write it under the touchscreen section. The syntax is in the file, and the mask needed can be found by using the ButtonSwap3DSHelper.jar provided.

As an example, the following file would make it so pressing the A button on your 3DS makes it think you’ve pressed the B button, pressing the SELECT button makes it think you’ve pressed both D-Pad Up and Down, and pressing the START button makes it think you’ve touched the screen at the (50,70) point:



Once your injected.s file is modified, you can make your cia. Once your cia is ready,transfer it to your 3DS, install it and run it. If you want to revert your mapping, reboot your 3DS.

For further customization, go into the meta folder. You can change the cia’s icon, banner and sound there. You can also edit cia.rsf and cia_mode3.rsf to change its name, description, and UniqueId. If you want to use different mappings (for different games, for example), remember to edit the UniqueId of one of them so you can have both mappings installed as different applications, instead of having to reinstall the cia every time you want to change mappings.
 
D

Deleted User

Guest
I originally started looking into swapping buttons when I got the MHGen hunting grip. I've always thought Nintendo's placement of the L/R and ZL/ZR is backwards from everyone else, and I don't like it. While searching for something to swap the two, I looked at the source for InputRedirection from @Stary2001. If you don't know how it works, it hooks into the HID process (which is responsible for user input), and redirects where the values for user input are read from in memory through Arm assembly.
His patch was pretty easy for me to read to see what was going on, and I thought, "What if we could get the values from what buttons were pressed, then modify the values before the value gets written to this redirected memory?" After some experimentation, it worked!

I've put quite a bit of work to make this as user-friendly as possible, but be aware of a few things:
  • This code works at almost the lowest level possible-assembly code; it is really hard to debug. As long as you don't touch the other functions (.single, .combo, .touch, .cpad), the worst that can happen is your console will get bad input data and be uncontrollable. Just reboot and try a different configuration.
  • You cannot reconfigure this on the 3DS! Every time you want to change your button mappings, you need to edit the injected file and recompile the program. Hopefully I can change that in the future - I'm open to help for this.
  • The C-stick and ZL/ZR are not mappable right now. I'm looking into hooking the IR process to achieve this.
  • The Home button and Power button are not remappable. These buttons use a separate part of the hardware, and there are no plans to make this possible.
  • While based on InputRedirection, it is not compatible. This program would overwrite any data sent by the InputRedirection desktop programs.
  • It can still be a bit buggy. It is designed to un-press any buttons that were pressed if you use touchscreen or C-pad mappings, but I noticed that it doesn't always work when used with combos. YMMV.
  • I've just merged with Stary's latest changes, but I haven't tested the Mode3 version, as I don't have an O3DS.
How To Use
Code is located at my repo: https://github.com/MikahJC/ButtonSwap3DS
You will need a working setup of the devkitARM toolchain for 3DS, follow this guide if you need help: https://www.3dbrew.org/wiki/Setting_up_Development_Environment.
You will also need this library by @Stary2001: https://github.com/Stary2001/ScenicRoute. Clone it, then run make install in the ScenicRoute directory.
Finally, clone the repository at https://github.com/MikahJC/ButtonSwap3DS.
The instructions for each type of mapping are provided in the source/injected.s file. I've provided a Java program to generate the correct button masks and coordinate values. When you have saved your mappings into this file, you will need to compile it. To build, change to the ButtonSwap3DS directory in a terminal, then run make.
This is the data that defines which buttons will activate the remapping and which buttons will be pressed as a result. Either use the provided program, or manually calculate the mask using this table. For example, this code would swap A and B:
Code:
ldr r4, =0x1
ldr r5, =0x2
bl .button
ldr r4, =0x2
ldr r5, =0x1
bl .button
The next two data fields are six-digit numbers. The first 3 digits are the Y coordinate data, and the last 3 digits are the X coordinate data.
The data that will be sent as the touchscreen. Use the provided tool to generate this data.
Data that will be sent as the c-pad. This data is a bit harder to calculate. The default value for the C-pad is 0x800800. To calculate this value, you will need to use the developer mode on your calculator. Xor 0x800800 by the value you want the C-pad to have. For example, if you want to have the C-pad pushed to the right, you would xor 0x800800 by 0x800FFF, giving you 0x7FF. Pad this with 3 zeroes in front (0x0007FF), and you have your data!
I've attached a basic version that swaps A and B for demonstration purposes.

Thanks and credit to @Stary2001. He wrote all of the injection code and almost all of the setup code. I just figured out how to mess with the values in-between. :)
2/15/2017: Uploaded a new zip with the mode3 version as well.
3/28/2017: @Vague Rant pointed out an error with the combo swap documentation. Thanks!
4/15/2017: Changed how button pressing and un-pressing works. As @Vague Rant and @rolim91 pointed out, multiple mappings had the possibility of affecting each other, resulting in undesirable results when multiple buttons were pressed. The new system maintains a record of which buttons need to be pressed and unpressed, then applies all changes at the end of the mapping process. My initial testing shows that it is working much better, but I appreciate any feedback if there are still bugs.
similar to hid to vpad. do i need to have a config file ready for this, or is it automatically created and edited from the 3ds?

--------------------- MERGED ---------------------------

i am looking just to swap “a” with “r” for mario kart 7
 
D

Deleted User

Guest
I originally started looking into swapping buttons when I got the MHGen hunting grip. I've always thought Nintendo's placement of the L/R and ZL/ZR is backwards from everyone else, and I don't like it. While searching for something to swap the two, I looked at the source for InputRedirection from @Stary2001. If you don't know how it works, it hooks into the HID process (which is responsible for user input), and redirects where the values for user input are read from in memory through Arm assembly.
His patch was pretty easy for me to read to see what was going on, and I thought, "What if we could get the values from what buttons were pressed, then modify the values before the value gets written to this redirected memory?" After some experimentation, it worked!

I've put quite a bit of work to make this as user-friendly as possible, but be aware of a few things:
  • This code works at almost the lowest level possible-assembly code; it is really hard to debug. As long as you don't touch the other functions (.single, .combo, .touch, .cpad), the worst that can happen is your console will get bad input data and be uncontrollable. Just reboot and try a different configuration.
  • You cannot reconfigure this on the 3DS! Every time you want to change your button mappings, you need to edit the injected file and recompile the program. Hopefully I can change that in the future - I'm open to help for this.
  • The C-stick and ZL/ZR are not mappable right now. I'm looking into hooking the IR process to achieve this.
  • The Home button and Power button are not remappable. These buttons use a separate part of the hardware, and there are no plans to make this possible.
  • While based on InputRedirection, it is not compatible. This program would overwrite any data sent by the InputRedirection desktop programs.
  • It can still be a bit buggy. It is designed to un-press any buttons that were pressed if you use touchscreen or C-pad mappings, but I noticed that it doesn't always work when used with combos. YMMV.
  • I've just merged with Stary's latest changes, but I haven't tested the Mode3 version, as I don't have an O3DS.
How To Use
Code is located at my repo: https://github.com/MikahJC/ButtonSwap3DS
You will need a working setup of the devkitARM toolchain for 3DS, follow this guide if you need help: https://www.3dbrew.org/wiki/Setting_up_Development_Environment.
You will also need this library by @Stary2001: https://github.com/Stary2001/ScenicRoute. Clone it, then run make install in the ScenicRoute directory.
Finally, clone the repository at https://github.com/MikahJC/ButtonSwap3DS.
The instructions for each type of mapping are provided in the source/injected.s file. I've provided a Java program to generate the correct button masks and coordinate values. When you have saved your mappings into this file, you will need to compile it. To build, change to the ButtonSwap3DS directory in a terminal, then run make.
This is the data that defines which buttons will activate the remapping and which buttons will be pressed as a result. Either use the provided program, or manually calculate the mask using this table. For example, this code would swap A and B:
Code:
ldr r4, =0x1
ldr r5, =0x2
bl .button
ldr r4, =0x2
ldr r5, =0x1
bl .button
The next two data fields are six-digit numbers. The first 3 digits are the Y coordinate data, and the last 3 digits are the X coordinate data.
The data that will be sent as the touchscreen. Use the provided tool to generate this data.
Data that will be sent as the c-pad. This data is a bit harder to calculate. The default value for the C-pad is 0x800800. To calculate this value, you will need to use the developer mode on your calculator. Xor 0x800800 by the value you want the C-pad to have. For example, if you want to have the C-pad pushed to the right, you would xor 0x800800 by 0x800FFF, giving you 0x7FF. Pad this with 3 zeroes in front (0x0007FF), and you have your data!
I've attached a basic version that swaps A and B for demonstration purposes.

Thanks and credit to @Stary2001. He wrote all of the injection code and almost all of the setup code. I just figured out how to mess with the values in-between. :)
2/15/2017: Uploaded a new zip with the mode3 version as well.
3/28/2017: @Vague Rant pointed out an error with the combo swap documentation. Thanks!
4/15/2017: Changed how button pressing and un-pressing works. As @Vague Rant and @rolim91 pointed out, multiple mappings had the possibility of affecting each other, resulting in undesirable results when multiple buttons were pressed. The new system maintains a record of which buttons need to be pressed and unpressed, then applies all changes at the end of the mapping process. My initial testing shows that it is working much better, but I appreciate any feedback if there are still bugs.
would it work to swap just “r” and “a”?
 

Lumper25

Member
Newcomer
Joined
May 14, 2019
Messages
6
Trophies
0
Age
47
XP
64
Country
United States
@AmberLoss Hey so I finally figured out how to do this thanks to your guide! Unfortunately I was hoping it would work with GBA VC games and it doesn't.

Any clue as to why?

Also any progress on zr/zl?
 

KleinesSinchen

GBAtemp's Backup Reminder + Fearless Testing Sina
Member
GBAtemp Patron
Joined
Mar 28, 2018
Messages
4,470
Trophies
2
XP
15,028
Country
Germany
[…]Unfortunately I was hoping it would work with GBA VC games and it doesn't.

Any clue as to why?[…]
Starting GBA games (the same with DS/DSi games) reboot into another operating system "AGB_Firm" or "TWL_FIRM".

Changes you apply in 3DS mode do not have an effect on the other modes.
 
Last edited by KleinesSinchen,
  • Like
Reactions: Tarmfot

Lumper25

Member
Newcomer
Joined
May 14, 2019
Messages
6
Trophies
0
Age
47
XP
64
Country
United States
Starting GBA games (the same with DS/DSi games) reboot into another operating system "AGB_Firm" or "TWL_FIRM".

Changes you apply in 3DS mode do not have an effect on the other modes.


Thats unfortunate but makes sense. I wonder if its possible to have this auto apply itself once the GBA firmware boots up.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • SylverReZ @ SylverReZ:
    They probably said "Hey, why not we combine the two together and make a 'new' DS to sell".
  • Veho @ Veho:
    It's a DS Lite in a slightly bigger DS Lite shell.
    +1
  • Veho @ Veho:
    It's not a Nintendo / iQue official product, it's a 3rd party custom.
    +1
  • Veho @ Veho:
    Nothing special about it other than it's more comfortable than the Lite
    for people with beefy hands.
    +1
  • Jayro @ Jayro:
    I have yaoi anime hands, very lorge but slender.
  • Jayro @ Jayro:
    I'm Slenderman.
  • Veho @ Veho:
    I have hands.
  • BakerMan @ BakerMan:
    imagine not having hands, cringe
    +1
  • AncientBoi @ AncientBoi:
    ESPECIALLY for things I do to myself :sad:.. :tpi::rofl2: Or others :shy::blush::evil:
    +1
  • The Real Jdbye @ The Real Jdbye:
    @SylverReZ if you could find a v5 DS ML you would have the best of both worlds since the v5 units had the same backlight brightness levels as the DS Lite unlockable with flashme
  • The Real Jdbye @ The Real Jdbye:
    but that's a long shot
  • The Real Jdbye @ The Real Jdbye:
    i think only the red mario kart edition phat was v5
  • BigOnYa @ BigOnYa:
    A woman with no arms and no legs was sitting on a beach. A man comes along and the woman says, "I've never been hugged before." So the man feels bad and hugs her. She says "Well i've also never been kissed before." So he gives her a kiss on the cheek. She says "Well I've also never been fucked before." So the man picks her up, and throws her in the ocean and says "Now you're fucked."
    +2
  • BakerMan @ BakerMan:
    lmao
  • BakerMan @ BakerMan:
    anyways, we need to re-normalize physical media

    if i didn't want my games to be permanent, then i'd rent them
    +1
  • BigOnYa @ BigOnYa:
    Agreed, that why I try to buy all my games on disc, Xbox anyways. Switch games (which I pirate tbh) don't matter much, I stay offline 24/7 anyways.
  • AncientBoi @ AncientBoi:
    I don't pirate them, I Use Them :mellow:. Like I do @BigOnYa 's couch :tpi::evil::rofl2:
    +1
  • cearp @ cearp:
    @BakerMan - you can still "own" digital media, arguably easier and better than physical since you can make copies and backups, as much as you like.

    The issue is DRM
  • cearp @ cearp:
    You can buy drm free games / music / ebooks, and if you keep backups of your data (like documents and family photos etc), then you shouldn't lose the game. but with a disk, your toddler could put it in the toaster and there goes your $60

    :rofl2:
  • cearp @ cearp:
    still, I agree physical media is nice to have. just pointing out the issue is drm
  • rqkaiju2 @ rqkaiju2:
    i like physical media because it actually feels like you own it. thats why i plan on burning music to cds
  • cearp @ cearp:
    It's nice to not have to have a lot of physical things though, saves space
    +1
  • AncientBoi @ AncientBoi:
    Nor clothes 🤮 . Saves on time, soap, water and money having to wash them. :D
    AncientBoi @ AncientBoi: Nor clothes 🤮 . Saves on time, soap, water and money having to wash them. :D