RegisterKeyMapping - Get the right hash to read the current binding

Hey!
Currently I am trying to get the current key binding for a custom binding set by RegisterKeyMapping. I have read here Create GET_KEY_MAPPING - #2 by TheIndra that every key registered with RegisterKeyMapping can be accessed by the joaat hash of the command.

So when I register a key mapping like this:
RegisterKeyMapping('+handsup', 'Hands Up', 'keyboard', 'i')

and caluclate the joaat hash for handsup:
JOAAT hash for "handsup" is "7066e9f8" | Md5Calc.com
I would expect that ~INPUT_7066E9F8~ in a help text should show me the key “I”. But it is just blank. ~INPUT_CONTEXT~ on the other hands shows the E button.

SetTextComponentFormat("STRING");
AddTextComponentString("Key: ~INPUT_7066E9F8~");
DisplayHelpTextFromStringLabel(0, 0, 1, -1);

In addition to that, deterministic_bubble wrote in the same post, that to get the normal keys, there is a function “get instructional button”.

I would guess that he means GET_CONTROL_INSTRUCTIONAL_BUTTON - Cfx.re Docs

GetControlInstructionalButton(padIndex: number, control: number, p2: Player);

but that takes an integer as the second parameter? I already tried to convert the joaat hash to decimal (1885792760) but that returns null.

Am I missing something here or is this considered a bug?

2 Likes

I use this website to get the correct name; however, I have found in the past that for whatever reason, some strings just seem not to work, so it may be worth tweaking it slightly and seeing if that works for you.

1 Like

Ohh, that hashes generated by that site seem to work. Nice, thank you.

Do you have any idea how to get the key behind ~INPUT_A315A1FE~ into a string? I would like to pass the mapped key to Nui.

Like I mentioned above, I already tried to convert the hex part of the hash to decimal and to put it in GetControlInstructionalButton but that doesn’t seem to work.

hash | 0x80000000 or so I believe

What I have tried:
RegisterKeyMapping('+handsup', 'Hands Up', 'keyboard', 'i')
+handsup should be ~INPUT_F53DC64D~. In the help text, that prints the correct Key.

So to get the key with GetControlInstructionalButton():
0xF53DC64D | 0x80000000 = -180500915

In JS:
console.log(GetControlInstructionalButton(2, -180500915, 1))
prints an empty string.

but hash | 0x80000000 seems to be correct.

Would make sense, it seems this native is doing an explicit control ID check only allowing base game controls before passing to the hooked get-name function.

Will fix.

3 Likes

:eyes:

Been wanting to do something like this and came across. Has this ever been fixed?

BUMP

I know theres a way to grab it by precomputing the jenkins hash… But is this a native yet?

Not yet, but here I explain a little bit more about what you can do with it