23 CCommand(
const char *name,
const char *description, std::function<
void()> handler)
24 : m_handler(handler), m_command(XPLMCreateCommand(name, description))
26 XPLMRegisterCommandHandler(m_command, callback,
false,
static_cast<void *
>(
this));
30 ~CCommand() { XPLMUnregisterCommandHandler(m_command, callback,
false,
static_cast<void *
>(
this)); }
39 static int callback(XPLMCommandRef, XPLMCommandPhase phase,
void *refcon)
41 if (phase == xplm_CommandBegin)
43 (
static_cast<CCommand *
>(refcon)->m_handler)();
48 std::function<void()> m_handler;
49 XPLMCommandRef m_command;