Where to implement input events
Jump to navigation
Jump to search
Input events can be implemented in either a Logic Component or a Console Component.
The general rule is to register and implement them in the Logic Component because the Console Component should be as simple as possible and contain as little logic as possible for performance reasons.
However, there is a significant exception:
- In any cockpit with duplicate gauges, like Multi-Function Displays (MFDs), for example, there is no way for a logic component to know which gauge the input event was initiated from. The Console component is aware of the gauge it is attached to and therefore can provide this information to a Logic component that implements the actual input event logic.
- Register the input event in the Console component with the following:
- REGISTER_INPUT_EVENT_MULTIPLE(_pOwnerEntity, this, &COCName::InputEvent, COCName, (wstring(_T("INPUT_EVENT_NAME")) + _sParentGaugeNameW).c_str(), _T("Input event handler"));
- and implement it like so:
- bool COCName::InputEvent( const int i_Param1 , const int i_Param2 )
{
CALL_ENTITY_ACTION_1(_pOwnerEntity, _T("ACTION_HANDLE_INPUT_EVENT"), _sParentGaugeNameW);
- bool COCName::InputEvent( const int i_Param1 , const int i_Param2 )
- return true;
}
- return true;
You can map this input event to one of the mouse regions on the MFDs.
- To do this open the SIMbox toolkit and select the entity that uses the input event. In the console preview window select 'Edit' to open the console editor.
- Select a MFD panel.
- Select the Console Component that registers the input event.
- Open the options pane and select the options tab. This will display all user inputs mapped to MFD buttons for the component.
- To add a new user input right click inside the 'User Input' tab and select 'New'. This will open the 'Mouse Region Event Settings' editor.
- Fill in the 'Name' with the mouse region you wish to use.
- Fill in the 'Left Button Down' with the name of the input event. Select ok and notice that the 'User Input' tab has added your input event.
- Save the console editor settings.
- Then in a Logic component implement the ACTION_HANDLE_INPUT_EVENT action to handle actual input event logic.