Build it into your mod
Keys and hooks
The component only knows the names of actions. Where the keys come from is your decision – and there is one rule that decides it.
Why the framework ships no bindings
The input configuration of the game, Configs/System/chimeraInputCommon.conf, is one file. If two addons both override it, one of them wins and the other one loses its actions –
without an error. A framework that shipped its own copy would silently remove the keys of every other mod that does the same. So the framework leaves the file alone.
| You build… | Do this |
|---|---|
| A mod without the SOFLAM Core | Define your own actions with your own names and enter the names on the component (step 2 of Add it to your optic). Your chimeraInputCommon.conf is then the only one. |
| A mod with the SOFLAM Core as a dependency | Do not ship a copy of the input configuration. The Core already defines the default actions below and puts them into the character, helicopter and turret contexts. Leave the attributes at their defaults. |
The default action names
These are the names the component uses when its key attributes are left alone. They are defined by the SOFLAM Core, not by the framework.
| Attribute | Default action | Key in the Core | Does |
|---|---|---|---|
m_sCycleAction | GTG_SOFLAM_VisionModeAction | I | Cycle normal / night vision / thermal |
m_sToggleNvThermalAction | GTG_SOFLAM_ToggleNvThermalAction | right mouse button | Straight between night vision and thermal |
m_sPaletteAction | GTG_SOFLAM_ThermalPaletteAction | J | Next palette |
m_sGainUpAction / m_sGainDownAction | GTG_SOFLAM_GainUpAction / _GainDownAction | Shift + wheel | Night-vision gain, thermal window |
m_sLaserPowerUpAction / m_sLaserPowerDownAction | empty | H + wheel (SOFLAM) | Laser power – the framework knows no laser, see the hook below |
Define your own actions
An action needs a name and an input source; a context decides where it is active. This is the shape of the real file, cut down to one action. The two
ActionRefs +{ ... } blocks add to contexts the game already has, so your keys work where the player looks through the optic: in the character weapon context
(handheld and mounted weapons) and, if your optic sits in a vehicle turret, in the turret context.
ActionManager {
Actions {
Action MyOptic_VisionModeAction {
InputSource InputSourceSum "{<unique id>}" {
Sources {
InputSourceValue "{<unique id>}" {
FilterPreset "click"
Input "keyboard:KC_I"
Filter InputFilterValue "{<unique id>}" {
}
}
InputSourceCombo "{<unique id>}" {
FilterPreset "gamepad:click"
Sources {
InputSourceValue "{<unique id>}" {
Input "gamepad0:shoulder_right"
}
InputSourceValue "{<unique id>}" {
Input "gamepad0:pad_up"
Filter InputFilterDown "{<unique id>}" {
}
}
}
}
}
}
}
// ... MyOptic_ToggleNvThermalAction, MyOptic_PaletteAction, MyOptic_GainUpAction, MyOptic_GainDownAction in the same way
}
Contexts {
ActionContext CharacterWeaponContext {
ActionRefs +{
"MyOptic_VisionModeAction"
"MyOptic_ToggleNvThermalAction"
"MyOptic_PaletteAction"
"MyOptic_GainUpAction"
"MyOptic_GainDownAction"
}
}
ActionContext TurretContext {
ActionRefs +{
"MyOptic_VisionModeAction"
"MyOptic_ToggleNvThermalAction"
"MyOptic_PaletteAction"
"MyOptic_GainUpAction"
"MyOptic_GainDownAction"
}
}
}
}
WeaponOpticsZoomIn sits in a context that is active only during weapon aiming and in turrets. A handheld device of the binoculars kind is aimed as a gadget, and the zoom keys never arrive until you add them to a context that is active there. The page about zoom on a handheld device shows what that took.N for its mode key; in a collection like that N did not reach the action at all, not even with shift (measured in a multiplayer test). It uses I and J now. Measure on a loaded server before you promise a key.Make the keys rebindable in the menu
An action in chimeraInputCommon.conf works, but players can only see and rebind it if the key binding menu lists it. That is a second file, Configs/System/keyBindingMenu.conf: a category with one entry per action. Each entry names the action and gives it a label.
SCR_KeyBindingMenuConfig {
m_KeyBindingCategories {
SCR_KeyBindingCategory "{<unique id>}" {
m_sName "MYOPTIC"
m_sDisplayName "My Optic"
m_KeyBindingEntries {
SCR_KeyBindingEntry "{<unique id>}" {
m_sActionName "MyOptic_VisionModeAction"
m_sDisplayName "Cycle Vision Mode"
m_sPreset "click"
}
// ... one entry per action
}
}
}
}
m_sPreset has to be the FilterPreset of the action’s input sources (click in the examples on this page). The menu stores a rebind under the action and the preset. An entry without a preset stores it under an empty preset that no source carries: the menu accepts the new key, and the game never uses it. In the log it shows as settingsClosed ... 'MyOptic_VisionModeAction_' with nothing behind the underscore. The SOFLAM Core had exactly this fault for six keys until version 3.1.2. For controllers the menu adds the device prefix itself; the controller sources of the example carry gamepad:click.What the menu can rebind
The key binding menu of the game assigns single keys. A rebind replaces all current binds of the action with the key the player presses. The advanced dialog offers a few more things, but the list is short:
| Offered in the advanced dialog | What |
|---|---|
| Special binds | Esc, mouse wheel up and down, mouse movement (vertical and horizontal) and the joystick directions. |
| A combination key | Only the left Alt key. The game’s list holds no other. |
| An action prefix | Press, release, click, single click, double click and a few more. |
So a default such as Shift + mouse wheel (the gain keys of the SOFLAM) or H + wheel (laser power) works for the player who keeps it, but nobody can rebuild it in the menu: after a rebind it is one plain key, and Reset to default brings the original back. Alt + wheel is the game’s zoom, and the wheel on its own belongs to the game’s “speed up”. If your default is a wheel combination, think about a plain key as a second default.
The empty laser hook
The component also registers two optional actions for “laser power up / down”. The framework has no laser, so the method behind them is an empty hook. Whoever has a laser fills it with a
modded class. This is the real one of the SOFLAM Core, shortened:
//! in the framework: empty on purpose
protected void GTG_AdjustLaserPower(int direction)
{
}
modded class GTG_SOFLAM_VisionModeComponent
{
override protected void GTG_AdjustLaserPower(int direction)
{
IEntity owner = GetOwner();
if (!owner)
return;
GTG_SOFLAM_BeamComponent beam = GTG_SOFLAM_BeamComponent.Cast(owner.FindComponent(GTG_SOFLAM_BeamComponent));
if (!beam)
return;
float current = beam.GTG_GetEffectiveLV(); // what the light carries right now
if (current < 0)
return;
GTG_SOFLAM_LaserDesignatorComponent designator = GTG_SOFLAM_LaserDesignatorComponent.FindOn(owner);
if (designator)
designator.AdjustLaserPower(current, direction); // direction: +1 one step up, -1 one step down
}
}
For your own device: modded class GTG_SOFLAM_VisionModeComponent, override GTG_AdjustLaserPower, translate direction into one step of whatever you have (a laser, a lamp, a zoom ring),
and enter the action names in m_sLaserPowerUpAction and m_sLaserPowerDownAction. Empty names mean no keys.