From: <sv...@ww...> - 2005-06-18 04:58:52
|
Author: mkrose Date: 2005-06-17 21:58:46 -0700 (Fri, 17 Jun 2005) New Revision: 1570 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Source/F16/UpFrontControls.cpp trunk/CSP/CSPSim/Source/F16/UpFrontControls.h Log: Convert F16 UFC to use InputEventChannels instead of static event handlers. ICP button events can then be captured by the UFC system and by the corresponding animation handlers. The animation handlers can also use the channels to transmit events back to the UFC system when clicked on in the 3D cockpit. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1570 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2005-06-17 06:55:16 UTC (rev 1569) +++ trunk/CSP/CSPSim/CHANGES.current 2005-06-18 04:58:46 UTC (rev 1570) @@ -1,6 +1,13 @@ Version 0.4.0 (in progress) =========================== +2005-06-18: onsight + * Convert F16 UFC to use InputEventChannels instead of static event + handlers. ICP button events can then be captured by the UFC system + and by the corresponding animation handlers. The animation handlers + can also use the channels to transmit events back to the UFC system + when clicked on in the 3D cockpit. + 2005-06-16: onsight * Refactor SimCore/Util/Callback.h. The new code achieves the same effect with a cleaner interface and much simpler logic. Corresponding Modified: trunk/CSP/CSPSim/Source/F16/UpFrontControls.cpp =================================================================== --- trunk/CSP/CSPSim/Source/F16/UpFrontControls.cpp 2005-06-17 06:55:16 UTC (rev 1569) +++ trunk/CSP/CSPSim/Source/F16/UpFrontControls.cpp 2005-06-18 04:58:46 UTC (rev 1570) @@ -24,12 +24,12 @@ #include "UpFrontControls.h" +#include "InputEventChannel.h" +#include "PageALOW.h" #include "PageCNI.h" -#include "PageALOW.h" #include "PageLIST.h" #include "PageSTPT.h" -#include <iostream> SIMDATA_REGISTER_INTERFACE(UpFrontControls) DEFINE_INPUT_INTERFACE(UpFrontControls) @@ -42,10 +42,43 @@ m_PageMap["STPT"] = new PageSTPT; } +UpFrontControls::~UpFrontControls() { } + +// helper for defining button handlers +#define UFC_REGISTER(CONTROL) \ + bus->registerChannel(new InputEventChannel(#CONTROL, this, &UpFrontControls::CONTROL)); + void UpFrontControls::registerChannels(Bus *bus) { - m_Display = bus->registerLocalDataChannel<AlphaNumericDisplay::Ref>("DED", new AlphaNumericDisplay(26, 5)); + m_Display = bus->registerLocalDataChannel<AlphaNumericDisplay::Ref>("DED", new AlphaNumericDisplay(26, 5)); + UFC_REGISTER(ICP_0); + UFC_REGISTER(ICP_1); + UFC_REGISTER(ICP_2); + UFC_REGISTER(ICP_3); + UFC_REGISTER(ICP_4); + UFC_REGISTER(ICP_5); + UFC_REGISTER(ICP_6); + UFC_REGISTER(ICP_7); + UFC_REGISTER(ICP_8); + UFC_REGISTER(ICP_9); + UFC_REGISTER(ICP_COM1); + UFC_REGISTER(ICP_COM2); + UFC_REGISTER(ICP_LIST); + UFC_REGISTER(ICP_IFF); + UFC_REGISTER(ICP_AA); + UFC_REGISTER(ICP_AG); + UFC_REGISTER(ICP_RCL); + UFC_REGISTER(ICP_SEQ); + UFC_REGISTER(ICP_RTN); + UFC_REGISTER(ICP_ENTR); + UFC_REGISTER(ICP_UP); + UFC_REGISTER(ICP_DN); + UFC_REGISTER(ICP_INC); + UFC_REGISTER(ICP_DEC); } +#undef UFC_REGISTER + + void UpFrontControls::importChannels(Bus* bus) { for (PageMap::iterator i = m_PageMap.begin(); i != m_PageMap.end(); ++i) { i->second->importChannels(bus); @@ -72,7 +105,6 @@ void UpFrontControls::ICP_INC() { transition(getActivePage()->ICP_INC()); } void UpFrontControls::ICP_DEC() { transition(getActivePage()->ICP_DEC()); } - void UpFrontControls::ICP_RTN() { m_Override = 0; transition("CNI"); Modified: trunk/CSP/CSPSim/Source/F16/UpFrontControls.h =================================================================== --- trunk/CSP/CSPSim/Source/F16/UpFrontControls.h 2005-06-17 06:55:16 UTC (rev 1569) +++ trunk/CSP/CSPSim/Source/F16/UpFrontControls.h 2005-06-18 04:58:46 UTC (rev 1570) @@ -42,7 +42,7 @@ // partially work depending on the system implementations. -class UpFrontControls: public System { +class UpFrontControls: public System, public sigc::trackable { public: SIMDATA_OBJECT(UpFrontControls, 0, 0) @@ -50,37 +50,16 @@ END_SIMDATA_XML_INTERFACE DECLARE_INPUT_INTERFACE(UpFrontControls, System) - BIND_ACTION("ICP_0", ICP_0); - BIND_ACTION("ICP_1", ICP_1); - BIND_ACTION("ICP_2", ICP_2); - BIND_ACTION("ICP_3", ICP_3); - BIND_ACTION("ICP_4", ICP_4); - BIND_ACTION("ICP_5", ICP_5); - BIND_ACTION("ICP_6", ICP_6); - BIND_ACTION("ICP_7", ICP_7); - BIND_ACTION("ICP_8", ICP_8); - BIND_ACTION("ICP_9", ICP_9); - BIND_ACTION("ICP_COM1", ICP_COM1); - BIND_ACTION("ICP_COM2", ICP_COM2); - BIND_ACTION("ICP_IFF", ICP_IFF); - BIND_ACTION("ICP_LIST", ICP_LIST); - BIND_ACTION("ICP_AA", ICP_AA); - BIND_ACTION("ICP_AG", ICP_AG); - BIND_ACTION("ICP_RCL", ICP_RCL); - BIND_ACTION("ICP_ENTR", ICP_ENTR); - BIND_ACTION("ICP_RTN", ICP_RTN); - BIND_ACTION("ICP_SEQ", ICP_SEQ); - BIND_ACTION("ICP_UP", ICP_UP); - BIND_ACTION("ICP_DN", ICP_DN); - BIND_ACTION("ICP_INC", ICP_INC); - BIND_ACTION("ICP_DEC", ICP_DEC); + // the various icp button events are declared dynamically in registerChannels END_INPUT_INTERFACE UpFrontControls(); + ~UpFrontControls(); virtual void registerChannels(Bus*); virtual void importChannels(Bus*); +protected: // event handlers virtual void ICP_0(); virtual void ICP_1(); |