Where to implement input events

From SIMboxWiki
Revision as of 17:47, 10 November 2010 by Seanjarvis (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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);
           return true;
}

     You can map this input event to one of the mouse regions on the MFDs.

  1. 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.
  2. Select a MFD panel.
    Mfd input 1.PNG
  3. Select the Console Component that registers the input event.
  4. Open the options pane and select the options tab. This will display all user inputs mapped to MFD buttons for the component.
    Mfd input 2.PNG
  5. 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.Mfd input 3.PNG
  6. Fill in the 'Name' with the mouse region you wish to use.
    Mfd input 4.PNG 
  7. 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.
    Mfd input 5.PNGMfd input 6.PNG 
  8. Save the console editor settings.


Then in a Logic component implement the ACTION_HANDLE_INPUT_EVENT action to handle actual input event logic.