mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Adds utility function to clean up and standardize the remapping handling for keybinds
Adds sanity check so if no remappable binds are found for an actionMap, it isn't listed in the controls menu Updates ExampleModule's keybinds to use new utility function
This commit is contained in:
parent
a304198abb
commit
44c894d335
3 changed files with 53 additions and 66 deletions
|
|
@ -8,4 +8,23 @@ function getMouseAdjustAmount(%val)
|
||||||
{
|
{
|
||||||
// based on a default camera FOV of 90'
|
// based on a default camera FOV of 90'
|
||||||
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
|
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";
|
if(!isObject( ExampleMoveMap ) )
|
||||||
$RemapCmd[$RemapCount] = "moveforward";
|
{
|
||||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
new ActionMap(ExampleMoveMap)
|
||||||
$RemapDevice[$RemapCount] = "keyboard";
|
{
|
||||||
$RemapDescription[$RemapCount] = "Forward Movement";
|
humanReadableName = "Example 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++;
|
|
||||||
|
|
||||||
$RemapName[$RemapCount] = "Ascend";
|
//------------------------------------------------------------------------------
|
||||||
$RemapCmd[$RemapCount] = "moveup";
|
// Set up remappable entries
|
||||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
//------------------------------------------------------------------------------
|
||||||
$RemapDevice[$RemapCount] = "gamepad";
|
addKeyRemap("Forward", "ExampleMoveMap", "keyboard", "moveForward", "Forward Movement");
|
||||||
$RemapDescription[$RemapCount] = "Makes the camera ascend";
|
addKeyRemap("Backward", "ExampleMoveMap", "keyboard", "movebackward", "Backward Movement");
|
||||||
$RemapCount++;
|
addKeyRemap("Strafe Left", "ExampleMoveMap", "keyboard", "moveleft", "Left Strafing Movement");
|
||||||
$RemapName[$RemapCount] = "Descend";
|
addKeyRemap("Strafe Right", "ExampleMoveMap", "keyboard", "moveright", "Right Strafing Movement");
|
||||||
$RemapCmd[$RemapCount] = "movedown";
|
addKeyRemap("Ascend", "ExampleMoveMap", "keyboard", "moveup", "Makes the camera ascend");
|
||||||
$RemapActionMap[$RemapCount] = "ExampleMoveMap";
|
addKeyRemap("Descend", "ExampleMoveMap", "keyboard", "movedown", "Makes the camera descend");
|
||||||
$RemapDevice[$RemapCount] = "gamepad";
|
addKeyRemap("Jump", "ExampleMoveMap", "keyboard", "jump", "Jump");
|
||||||
$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";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Non-remapable binds
|
// Non-remapable binds
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,23 @@ function fillRemapList()
|
||||||
|
|
||||||
%actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName;
|
%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 $= "")
|
if(%actionMapList $= "")
|
||||||
%actionMapList = %actionMapName;
|
%actionMapList = %actionMapName;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue