mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #931 from Areloch/KeybindRemapCleanup
Cleanup and standardization of keybind remapping handling
This commit is contained in:
commit
fc1bbabe46
|
|
@ -8,4 +8,23 @@ function getMouseAdjustAmount(%val)
|
|||
{
|
||||
// based on a default camera FOV of 90'
|
||||
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
|
||||
}
|
||||
|
||||
function addKeyRemap(%name, %actionMap, %device, %command, %description)
|
||||
{
|
||||
if(%name $= "" ||
|
||||
%actionMap $= "" ||
|
||||
%device $= "" ||
|
||||
%command $= "")
|
||||
{
|
||||
error("addKeybindRemap() - tried to add a remap entry, but didn't have all the keeded info!");
|
||||
return;
|
||||
}
|
||||
|
||||
$RemapName[$RemapCount] = %name;
|
||||
$RemapCmd[$RemapCount] = %command;
|
||||
$RemapActionMap[$RemapCount] = %actionMap;
|
||||
$RemapDevice[$RemapCount] = %device;
|
||||
$RemapDescription[$RemapCount] = %description;
|
||||
$RemapCount++;
|
||||
}
|
||||
|
|
@ -1,70 +1,21 @@
|
|||
$RemapName[$RemapCount] = "Forward";
|
||||
$RemapCmd[$RemapCount] = "moveforward";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Forward Movement";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Backward";
|
||||
$RemapCmd[$RemapCount] = "movebackward";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Backward Movement";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Strafe Left";
|
||||
$RemapCmd[$RemapCount] = "moveleft";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Left Strafing Movement";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Strafe Right";
|
||||
$RemapCmd[$RemapCount] = "moveright";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Right Strafing Movement";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Ascend";
|
||||
$RemapCmd[$RemapCount] = "moveup";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Makes the camera ascend";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Descend";
|
||||
$RemapCmd[$RemapCount] = "movedown";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Makes the camera descend";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Jump";
|
||||
$RemapCmd[$RemapCount] = "jump";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "keyboard";
|
||||
$RemapDescription[$RemapCount] = "Jump";
|
||||
$RemapCount++;
|
||||
if(!isObject( ExampleMoveMap ) )
|
||||
{
|
||||
new ActionMap(ExampleMoveMap)
|
||||
{
|
||||
humanReadableName = "Example Movement";
|
||||
};
|
||||
}
|
||||
|
||||
$RemapName[$RemapCount] = "Ascend";
|
||||
$RemapCmd[$RemapCount] = "moveup";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "gamepad";
|
||||
$RemapDescription[$RemapCount] = "Makes the camera ascend";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Descend";
|
||||
$RemapCmd[$RemapCount] = "movedown";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "gamepad";
|
||||
$RemapDescription[$RemapCount] = "Makes the camera descend";
|
||||
$RemapCount++;
|
||||
$RemapName[$RemapCount] = "Jump";
|
||||
$RemapCmd[$RemapCount] = "jump";
|
||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
||||
$RemapDevice[$RemapCount] = "gamepad";
|
||||
$RemapDescription[$RemapCount] = "Jump";
|
||||
$RemapCount++;
|
||||
|
||||
if ( isObject( ExampleMoveMap ) )
|
||||
ExampleMoveMap.delete();
|
||||
|
||||
new ActionMap(ExampleMoveMap);
|
||||
ExampleMoveMap.humanReadableName = "Example Movement";
|
||||
//------------------------------------------------------------------------------
|
||||
// Set up remappable entries
|
||||
//------------------------------------------------------------------------------
|
||||
addKeyRemap("Forward", "ExampleMoveMap", "keyboard", "moveForward", "Forward Movement");
|
||||
addKeyRemap("Backward", "ExampleMoveMap", "keyboard", "movebackward", "Backward Movement");
|
||||
addKeyRemap("Strafe Left", "ExampleMoveMap", "keyboard", "moveleft", "Left Strafing Movement");
|
||||
addKeyRemap("Strafe Right", "ExampleMoveMap", "keyboard", "moveright", "Right Strafing Movement");
|
||||
addKeyRemap("Ascend", "ExampleMoveMap", "keyboard", "moveup", "Makes the camera ascend");
|
||||
addKeyRemap("Descend", "ExampleMoveMap", "keyboard", "movedown", "Makes the camera descend");
|
||||
addKeyRemap("Jump", "ExampleMoveMap", "keyboard", "jump", "Jump");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Non-remapable binds
|
||||
|
|
|
|||
|
|
@ -145,6 +145,23 @@ function fillRemapList()
|
|||
|
||||
%actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName;
|
||||
|
||||
//see if we have any actual listed remappable keys for this movemap. if so, drop it from the listing
|
||||
%hasRemaps = false;
|
||||
for ( %r = 0; %r < $RemapCount; %r++ )
|
||||
{
|
||||
%testMapName = $RemapActionMap[%r].humanReadableName $= "" ? $RemapActionMap[%r].getName() : $RemapActionMap[%r].humanReadableName;
|
||||
|
||||
if(%actionMapName $= %testMapName)
|
||||
{
|
||||
//got a match to at least one, so we're ok to continue
|
||||
%hasRemaps = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!%hasRemaps)
|
||||
continue;
|
||||
|
||||
if(%actionMapList $= "")
|
||||
%actionMapList = %actionMapName;
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue