Legacy:Input

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 11:27, 21 October 2004 by Wormbo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Object >> Subsystem >> Input (Package: Engine)

This is the native Engine.Input class, which holds the aliases and keybinds configured in the User.ini file.

Hypothetical Properties

TAlias Aliases[40] (config)
string Bindings[256] (config)
Actually this is no array in the User.ini file but 256 configurable variables with individual names like "Alt", "F6", "MouseX" (with is actually a movement axis, not a button), "Unknown3C", etc. Just have a look at your User.ini for a complete list.

Hypothetical Structs

TAlias

name Alias
The name of the alias. If an existing console command's name ins specified, this coneole command will be overridden by the alias.
string Command
The command this alias executes. Commands in here are actual functions, no aliases!

Accessing The Input Configuration

While it is possible to compile code that references class'Input' or Input objects, it's not possible to access properties of purely native classes directly in UnrealScript. (compiles fine, but crashes the game)

To work around this problem you first need a reference to an Input object. Under UT200x you can easily get such a reference with the following code:

<uscript> local Input MyInput;

foreach AllObjects(class'Input', MyInput)

 break;

</uscript>

The variable MyInput will then contain the currently used Input object.

In UT there is no AllObjects iterator, so you have to resort to a little trick with the SetPropertyText() function:

<uscript> var Input MyInput;

function GetInput() {

 SetPropertyText("MyInput", "Input'Input0'");

} </uscript>

The Input object should always have this name, so SetPropertyText() assigns it to the MyInput class variable. You could use this unter UT200x as well, but depending on whether the game was started with the -makenames- parameter you have to use either "Input'Input'" (without) or "Input'Input0'" (with) to get the desired effect.

Either way you can now access the Input object with the GetPropertyText function:

<uscript> // log the command bound to the left mouse button log(MyInput.GetPropertyText("LeftMouse")); </uscript>

Under UT2004 you can also access the Aliases array this way, but you will probably have to parse the array string first.

Beginning with UT2004 v3270 there's also an easier method of accessing aliases and keybinds using the Security class LocalPerform() function with a SecType of 100 and 101 respectively. See the UnrealScript Source of the XGame.XPlayer class for an implementation example. It's a good idea to spawn a new Security actor there, because the custom Security actors of Anti TCC and probably also SafeGame won't allow others to access their LocalPerform() function.