MZ Force a keyboard key press, while using Gamepad.

Hey guys,
I rarely ask for help but I have a complex issue I am trying to solve.
I have Irina's Tool wheel system (that is working on MZ) but it is mapped in the script to only work for keyboard controls. You need to map a keyboard button to press to use the active tool.

I am making my game to run exclusively on gamepad (mostly due to a custom script that is specially set up for gamepad use) and Irina's Tools work except I can't activate the tool with the gamepad.

I am wondering if there is a way call a script or force a keyboard button press so I can trigger Irina's script.

I.E. setting Irina's tool activate function to "+" key or "-" key on keyboard. Then setting a gamepad button to call a common event that triggers "+' or "-" button keyboard button press, thus bypassing the limits of the script.

If anyone could help that would be fantastic.
you need to go at it in a slightly different way. Modifying the keyboard buffer has too many risky side-effects, a good Antivirus should actively prevent that as a basic security feature.

however, somewhere in the code of the plugin is a routine that monitors input and triggers the function you want. you need to analyse the plugin to find that routine, learn from it the function name that is triggered by the keypress and then work a direct call to that function into your game, without going through the keyboard at all.
you need to go at it in a slightly different way. Modifying the keyboard buffer has too many risky side-effects, a good Antivirus should actively prevent that as a basic security feature.

however, somewhere in the code of the plugin is a routine that monitors input and triggers the function you want. you need to analyse the plugin to find that routine, learn from it the function name that is triggered by the keypress and then work a direct call to that function into your game, without going through the keyboard at all.

Really? There is no way to script call this or anything? It would really be that risky. That sounds surprising to me but this is a realm slightly beyond my coding understanding.

I've looked through it a few times but again I am not well versed in js or anything. Is there a key phrase or advice you can give me for the kind of phrase I am looking for?

I am guessing I am not allowed to post Irina's code for analysis am I?
t would really be that risky.
just imagine - a website being able to trigger a computer function that requires admin rights, then using the keyboard buffer to enter a password into the windows security check as if it was entered by someone on the keyboard.
If a HTML-Game could enter a keypress, that would be the same function and would be able to be used to circumvent a lot of the security features that require password confirmation.


You cannot post the code, but you can (and always should) post a link to the website where the plugin comes from if you want any help with it.
Hmm I guess that makes sense.

Well if anyone knows Irina's tool ring well ( https://atelieririna.itch.io/tool-ring-system) or knows of a similar system for MZ for a quick inventory to common event, linked items.

Then I'd love some help for how I can trigger this with a gamepad only. Is there a way to insert gamepad as options into Irina's tool ring?

I know Irina is impossible to contact for direct help.
It requires some additional settings, but my plugin may be able to handle it.
My plugin has the ability to assign to the gamepad the input information that is set only on the keyboard.
If you want to try to do this yourself:

Based on the itch screenshot
NH8HzX.png

There should be a plugin parameter tied to "Open Tool Ring Key". The associated code will store whatever this plugin parameter is set to into a variable, which probably will only be referenced in the 'open tool ring key' function.

Since I can't see the plugin, here's an example of tracing down the 'attack' skill input in chrono engine using the same procedure.

Here's the chrono engine attack param
Code:
*
* @param Attack Button
* @desc Definição do botão de ataque.
* ( x , c , a , s , d , ok , pagedown , pageup , shift )
* @default ok

So we do a find for "Attack Button" in the code, and get
Code:
Moghunter.ras_buttonWeapon = String(Moghunter.parameters['Attack Button'] || 'ok');

Our variable we are looking for is "Moghunter.ras_buttonWeapon"
We do a search for that, and find this function
Code:
Game_Player.prototype.commandAttackUsable = function() {
    if (!$gameSystem._chronoCom.attack) {return false};
    if (Input.isTriggered(Moghunter.ras_buttonWeapon)) {return true};
    return false;   
};

We now know that we can replace that "Input.isTriggered(Moghunter.ras_buttonWeapon)" with whatever your gamepad input is, and it will act like you pressed that instead of using your weapon button.
RM has a layer of abstraction between raw inputs and the game proper, so simulating an input isn't a big deal. There are separate key-code -> key-name maps for keyboard and gamepad inputs.

If you know the key name(s) then you could simply add them to the gamepad mapper. The easiest way would be with a gamepad-config plugin, like siguren suggests. Otherwise you could write your own overrides, e.g. stick something like this in a .js file and import as a plugin:
JavaScript:
Input.gamepadMapper[keyCode] = "keyName";
Add one line per input, replacing:
  • keyCode with a number (identifies input), and
  • keyName with the engine's name for the button (determines game response).
I don't know what key names Irina's plugin uses: if it's not mentioned in the plugin help, you can check the currently-recognised keyboard inputs for clues:
  1. Start a playtest
  2. Press F8 to show the console
  3. Type Input.keyMapper, then press Enter
You may find this site helpful for determining key-codes (I assume it also works with gamepads):

In case it helps, RMMZ offers an Input.virtualClick method, e.g.
JavaScript:
Input.virtualClick('pageup')
This simulates a 1-frame input signal: "Page Up", "Q", or gamepad LB in this case. Still requires you to know the key name, though.
Spoiler: Technical: testing via console
If you want to test via the console then I suggest something like setTimeout(() => Input.virtualClick('menu'), 1000), then focus the game window before the timeout expires.
So I am not quite big brained enough to understand code. But I am wondering if Irina's script has a big problem here. When I go to the bottom of the txt window, I am assuming above the line is commenting for the purpose of the description and plugin vocabulary. But below this line is the actual code. In which case Irina has written some of the sloppiest code I've ever seen and this is nearly incomprehensible to me. Would it be haystack diving trying to follow some of the suggestions above in here.

I am just wondering how much would be worth my time, I would love to try editing the plugin myself but I am not quite skilled enough for that.

1620012550845.png


It requires some additional settings, but my plugin may be able to handle it.
My plugin has the ability to assign to the gamepad the input information that is set only on the keyboard.
In my current understanding my hands are a bit bound with the controller plugin I am using.

I am making the game primarily for use with the MV3D/MZ3D plugin. So a control input has to allow for functions to rotate the camera which have been tweaked to a current controller option.

I was actually working with very generous help from a guy called Coopninjask who I would love to get in contact with again. But I went on break from my game due to corona in my country affecting lifestyle and when I came back refreshed, Coopninjask who was investing heavily in the environmental system for 3D had vanished from the internet and deleted everything and all his plugins due to seemingly sharing cutievirus's MV plugin through profit.

Anyway he made me some custome control plugins where as well as use MV3D's mapped camera I can also open common events with button presses. So far I haven't had luck with other control scripts providing what I need inm my jury rigged spaghetti code of a game but if you think your control plugin could help, do you mind explaining how so in a bit more detail?
So I am not quite big brained enough to understand code. But I am wondering if Irina's script has a big problem here. When I go to the bottom of the txt window, I am assuming above the line is commenting for the purpose of the description and plugin vocabulary. But below this line is the actual code. In which case Irina has written some of the sloppiest code I've ever seen and this is nearly incomprehensible to me. Would it be haystack diving trying to follow some of the suggestions above in here.

I am just wondering how much would be worth my time, I would love to try editing the plugin myself but I am not quite skilled enough for that.

View attachment 188194
is that Irina's Plugin you mentioned? if yes....
you're in bad luck... it seem Irina also follow VisuStella path with Obfuscating the codes...
by obfuscating the code... it will be really hard for human to read the code...
it's not because Irina write the sloppiest code like you said... but it's done intentionally...
it's a technique to make other people cannot steal the code easily... human cannot read it easily but machine can still read it fine... but this technique also have bad effect...
other people beside the plugin maker might not be able to help you if you have problem with the plugin... (or at least the help is very limited). and if there's compatibility issue with other plugin... other people also cannot help you...

so my advice is try to contact Irina directly and ask for his/her support...
That's also why I always give advice to people having problem/compatibility issues with VisuStella plugin to directly contact VisuStella team because of the same reason...

hope this help....
Ah dang it. So that is how they get away with it. I had no idea that was a thing.

My understanding is Irina is notorious for being impossible to contact. Their youtube and itch.io lack methods of contact. But I am open to other ideas if people have them.

Thank you for explaining that to me though.
is that Irina's Plugin you mentioned? if yes....
you're in bad luck... it seem Irina also follow VisuStella path with Obfuscating the codes...
by obfuscating the code... it will be really hard for human to read the code...
thus other people beside the plugin maker might not be able to help you... (or at least the help is very limited).

so my advice is try to contact Irina directly and ask for his/her support...

hope this help....
Ah dang it. So that is how they get away with it. I had no idea that was a thing.

My understanding is Irina is notorious for being impossible to contact. Their youtube and itch.io lack methods of contact. But I am open to other ideas if people have them.

Thank you for explaining that to me though.
i think you can try doing @caethyril suggestion above... it's your best bet actually...

edit: maybe try the plugin posted in this post too as alternative...
i'm not sure though since the plugin is from japanese author... but what make it interesting that it have
Automatic capture of unknown symbols feature... thus it might be able to read Irina's keyboard keyname... not sure on how to use it though... but it's worth a try 😀.

hope this help.
RM has a layer of abstraction between raw inputs and the game proper, so simulating an input isn't a big deal. There are separate key-code -> key-name maps for keyboard and gamepad inputs.

If you know the key name(s) then you could simply add them to the gamepad mapper. The easiest way would be with a gamepad-config plugin, like siguren suggests. Otherwise you could write your own overrides, e.g. stick something like this in a .js file and import as a plugin:
JavaScript:
Input.gamepadMapper[keyCode] = "keyName";
Add one line per input, replacing:
  • keyCode with a number (identifies input), and
  • keyName with the engine's name for the button (determines game response).
I don't know what key names Irina's plugin uses: if it's not mentioned in the plugin help, you can check the currently-recognised keyboard inputs for clues:
  1. Start a playtest
  2. Press F8 to show the console
  3. Type Input.keyMapper, then press Enter
You may find this site helpful for determining key-codes (I assume it also works with gamepads):

In case it helps, RMMZ offers an Input.virtualClick method, e.g.
JavaScript:
Input.virtualClick('pageup')
This simulates a 1-frame input signal: "Page Up", "Q", or gamepad LB in this case. Still requires you to know the key name, though.
Spoiler: Technical: testing via console
If you want to test via the console then I suggest something like setTimeout(() => Input.virtualClick('menu'), 1000), then focus the game window before the timeout expires.
I am still trying to get my head around what Caethyril is suggesting.

This is what the input look up has returned:
1620025709745.png

I seem to have double-ups of inputs not sure if that affects anything.

But then I take this data and try to add it to the gamepad input plugin? One of the OKs may be the button for Irina?
Describes Mano_InputConfig.
This plugin makes minimal changes to the game behavior.
It only provides a way to rewrite Input.gamepadMapper and Input.keyMapper, and you can think that it will not conflict with the plugin created by Coopninjask.

There are multiple "ok" symbols, but RPG maker originally had this setting.
Added by Irina's plugin is 36: rotright.
To make it available on your gamepad, you can do the following:

1. Install Mano_InputConfig.
2. Launch the game, enter the keyconfig scene and press reset. Then press save to save your settings.
3. Open keyconfig again and hover over the symbol with a different color.
Information will appear in the window on the screen, so add the settings to the plugin parameters extendsMapper accordingly.
If you don't know, please upload the game screen.
Moved to: Plugin Support

Original thread: https://forums.rpgmakerweb.com/threads/force-a-keyboard-key-press-while-using-gamepad.135864/