[WIP] ButtonSwap3DS - Remap buttons on your 3DS

Discussion in '3DS - Homebrew Development and Emulators' started by mcaboosec, Feb 13, 2017.

  1. mcaboosec
    OP

    mcaboosec Member

    Newcomer
    33
    64
    Sep 15, 2009
    United States
    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
    Build Environment
    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.
    Each data field, and how to get it
    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. :)
    Changelog
     

    Attached Files:

    Last edited by mcaboosec, Apr 15, 2017
  2. Quantumcat

    Quantumcat Dead and alive

    Member
    11,592
    6,231
    Nov 23, 2014
    Australia
    Canberra, Australia
    Amazing. This will help lots of people - a question gets asked about this every week or so.
     
  3. gkoelho

    gkoelho GBAtemp Advanced Fan

    Member
    547
    133
    Apr 16, 2015
    Brazil
    I can recall a lot of people wanting this. Should be great, nice work.
     
  4. Stary2001

    Stary2001 Newbie

    Newcomer
    7
    10
    Aug 1, 2016
    Interesting - good work! I might look into being able to make it configurable on the 3DS itself somehow, via a background service or something. If that's doable I'll look into merging this into mainline InputRedirection, as it seems like a logical next step :)
    Also,
    I've looked into IR a bit - can we work together on this?
     
    renhei, Quantumcat, rphlfjrd and 3 others like this.
  5. Exavold

    Exavold lol

    Member
    1,004
    1,061
    Nov 9, 2015
    France
    lol
    Does that mean that could be able to use ZL and ZR on o3DS ..?
     
  6. xtheman

    xtheman GBAtemp Guru

    Member
    5,847
    5,279
    Jan 28, 2016
    United States
     
    Exavold likes this.
  7. coinblock

    coinblock GBAtemp Regular

    Member
    213
    92
    Sep 4, 2015
    Does this work with AGB_FIRM? I'm guessing no?
     
  8. Alex658

    Alex658 GBAtemp Maniac

    Member
    1,152
    340
    Jun 4, 2010
    Venezuela
    Venezuela
    If this is a CTR program/app you'd lose arm11 control as soon as you boot up TWL or AGB modes... Since the 3ds downclocks itself, basically.

    This is why you can't possibly use hans/ntr/etc on thosr modes.
     
  9. ChrisN8

    ChrisN8 GBAtemp Fan

    Member
    324
    89
    May 13, 2015
    France
    amazing ! i tried the a to b .cia and it works fine. I hope it will end in a easy remapper, New3ds have a lot of button that Nintendo doesn't even care to use them correctly...
     
    Last edited by ChrisN8, Feb 14, 2017
  10. DeoNaught

    DeoNaught ¯\_(ツ)_/¯

    Member
    1,567
    1,600
    Aug 22, 2016
    United States
    Constant Fear
    Video?
     
  11. mcaboosec
    OP

    mcaboosec Member

    Newcomer
    33
    64
    Sep 15, 2009
    United States
    Not right now, but it's an interesting thought. I'm not sure if it would work given that the hardware is built into the N3DS, but was available to the O3DS via the circle pad pro attachment. Most games on the N3DS that use ZL and ZR also report that the CPP is attached.

    Sure! I've looked at ShinyQuagsire's writeup, but haven't had much luck trying to figure out the IR process myself.
     
    renhei, rphlfjrd and Exavold like this.
  12. martorSkul

    martorSkul Member

    Newcomer
    14
    2
    Jan 21, 2017
    Argentina
    I remembered when you posted looking for this and now you've made it. Really proud :lol::D
     
    Quantumcat and Exavold like this.
  13. iHateEggBreeding

    iHateEggBreeding Member

    Newcomer
    23
    2
    Jul 17, 2016
    Norway
    .
     
    Last edited by iHateEggBreeding, Mar 8, 2017
    martorSkul likes this.
  14. martorSkul

    martorSkul Member

    Newcomer
    14
    2
    Jan 21, 2017
    Argentina
    someone make this real
     
  15. mcaboosec
    OP

    mcaboosec Member

    Newcomer
    33
    64
    Sep 15, 2009
    United States
    Yep, my bad. I originally only uploaded the standard version. I just attached a new zip with the mode3 cia as well.

    Ask and ye shall receive! ;)
     

    Attached Files:

  16. iAqua

    iAqua

    Member
    2,834
    2,463
    Dec 7, 2015
    Antarctica
    I love you.
     
    mcaboosec likes this.
  17. iHateEggBreeding

    iHateEggBreeding Member

    Newcomer
    23
    2
    Jul 17, 2016
    Norway
    .
     
    Last edited by iHateEggBreeding, Mar 8, 2017
  18. Vague Rant

    Vague Rant Deceptively cute

    Member
    2,053
    414
    Aug 7, 2008
    Melbourne
    Buh? What Super Mario World did you play? It's always been Y to dash and B to jump.
     
    Zidapi and Kyouken like this.
  19. BARNWEY

    BARNWEY Legen-wait for it-dary

    Member
    1,268
    533
    Oct 11, 2016
    United States
    Good job dude! Looks interesting...
     
  20. ChrisN8

    ChrisN8 GBAtemp Fan

    Member
    324
    89
    May 13, 2015
    France
    So... is it possible to have a A <> Y version ?
    By the way does your App switch the button between two specifify input or can assign any input or any button ?