Tons of Addons 'Custom Controls' feature makes If Button is Pressed commands not work

As per the title, I've been using Blizzard's Tons of Addons script for my RMXP project and have been having problems with the Custom Controls feature.

When flagged as true, event commands that look for buttom presses stop working
Code:
CUSTOM_CONTROLS        = true
I tried making a journal following this tutorial, and a Running Toggle. To test that this was indeed the case, I made a fresh project with just Tons of Addons Part 1, Part 2 and Part 3 scripts, and made these common events to test:
1708373687589.png
1708373755000.png


When
Code:
CUSTOM_CONTROLS        = false
both events would work as intended.
When
Code:
CUSTOM_CONTROLS        = true
both events would fail to recognize buttons being pressed. In the case of the book, the player would get stuck in the first image of the book. In the case of the running toggle, the player would be stuck with the speed applied in the Else.

So I'm asking for three things really:
1. Is there a script that patches this problem in Tons of Addons?
2. Is there other ways to get button presses to be recognized by the Conditional branch command?
3. The reason I was using Custom Controls was because I wanted the player to move using WASD instead of Arrow Keys. What are other custom control scripts that would allow me to have WASD movement *and* get buttons presses recognized?

EDIT: Testing random stuff, I installed an english keyboard setup. And *that* made these things work.
4th question: As I'm not comfortable just blindly editing Tons of Addons to identify a spanish keyboard configuration, I want to ask now how I would go about it. (Should I just tell the players to switch their keyboard setup to english? That would be the quickest and dirtiest way to bandaid the problem away...)

EDIT 2: As the problem appears to be the script being unable to recognize the keyboard config, I'd rather stick with Tons of Addons and find a way to fix this problem. Would it be possible to get this post moved to Script Support?


EDIT 3: I'm going crazy, the first EDIT was a false positive, I tested again with english keyboard setup and nothing worked, and now I can't tell why.
Well, the default implementation is supposed to be used as a "keep pressing the button" kind of option...
I remember fixing some bugs with Custom Controls back in the day, this was probably one of them.

Throw this script in somewhere after the Tons of Add-ons scripts:
Ruby:
if TONS_OF_ADDONS::CUSTOM_CONTROLS
  class Interpreter
    #--------------------------------------------------------------------------
    # * Conditional Branch
    #--------------------------------------------------------------------------
    OldInputMap = {
      2 => Input::DOWN, 4 => Input::LEFT, 6 => Input::RIGHT, 8 => Input::UP,
      11 => Input::A, 12 => Input::B, 13 => Input::C, 14 => Input::X,
      15 => Input::Y, 16 => Input::Z, 17 => Input::L, 18=> Input::R
    }
 
    alias blizz_cc_cmd_111_fix command_111
    def command_111
      # call original method if this isn't a "Button is being pressed" condition
      return blizz_cc_cmd_111_fix unless @parameters[0] == 11
 
      keys = OldInputMap[@parameters[1]]
      result = Input.press?(keys)
      # Store determinant results in hash
      @branch[@list[@index].indent] = result
      # If determinant results are true
      if @branch[@list[@index].indent] == true
        # Delete branch data
        @branch.delete(@list[@index].indent)
        # Continue
        return true
      end
      # If it doesn't meet the conditions: command skip
      return command_skip
    end
  end
end
Spoiler: Explanation
The problem is that the editor saves button inputs based on the old constant values that module Input used to have. So a button check for if "A" is pressed was checking if the key associated with a value of 11 (the value of Input::A) is being pressed.

Custom Controls changes the value of Input::A with arrays of virtual key codes. For example, according to the default configuration...
Ruby:
module Input
  Key = { ..., 'Shift' => 16, ... }

  A = [Key['Shift']]
This is assigning Input::A to a value of the array [16]. You can see the problem now how the conditional branch is checking if 11 is pressed, when in actuality you want to be checking for 16. Thus, the solution is to use the OldInputMap to associate the old integer values to the new Custom Controls values.
Alternatively, you can use the "Script" option in a Conditional Branch (right below the "Button" option) and input the following:
Code:
Input.press?(Input::A)
or if you're looking for a specific key on the keyboard, e.g.:
Code:
Input.press?(Input::Key['Shift'])
Throw this script in somewhere after the Tons of Add-ons scripts:
It worked! Thank you very much.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/tons-of-addons-custom-controls-feature-makes-if-button-is-pressed-commands-not-work.165952/