Hello,
I try to coordinate 2D and 3D panels using custom events.
1) In gauges.h I have declared the new events:
// Third parties can use custom events in this range to communicate between 3D VC's and 2D C++ gauges.
#define THIRD_PARTY_EVENT_ID_MIN 0x00011000
#define THIRD_PARTY_EVENT_ID_MAX 0x0001FFFF
// Third party events
const int KEY_PHI_MODE_INC = 0x11000; //THIRD_PARTY_EVENT_ID_MIN
const int KEY_PHI_MODE_DEC = 0x11001;
2) I have an EventHandler in my sub-gauge :
// GAUGE_KEY_EVENT_HANDLER
static void FSAPI EventHandler(ID32 event, UINT32 evdata, PVOID userdata)
{
switch(event)
{
case KEY_NULL :
break;
case KEY_PHI_MODE_INC:
HomingState++;
if(HomingState>4)
HomingState=0;
break;
case KEY_PHI_MODE_DEC:
HomingState--;
if(HomingState<0)
HomingState=4;
break;
default:
break;
}
}
These 2 events increase/decrease by step of Homingstate (SINT32 variable) a rotactor to set its position (0 to 4)
3) I Have registered and unregistered this EventHandler in mysub-gauge callback :
static void FSAPI gauge_cb( PGAUGEHDR pgauge, int service_id, UINT32 extra_data )
{
switch(service_id)
{
case PANEL_SERVICE_CONNECT_TO_WINDOW:
{
register_key_event_handler((GAUGE_KEY_EVENT_HANDLE R) EventHandler, NULL);
break;
}
case PANEL_SERVICE_PRE_INSTALL:
break;
case PANEL_SERVICE_PRE_UPDATE:
........
break;
case PANEL_SERVICE_DISCONNECT:
{
unregister_key_event_handler((GAUGE_KEY_EVENT_HAND LER) EventHandler, NULL);
break;
}
case PANEL_SERVICE_PRE_KILL:
break;
}
}
4) I call the events with 2 mouse callbacks and update the 3D corresponding element
static BOOL FSAPI switch_inc_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags )
{
trigger_key_event(KEY_PHI_MODE_INC,0);
set_named_variable_value(phi_mode_id,HomingState);
return FALSE;
}
Everything works well except that the increasing step for Homingstate var is 2 and not 1.
If I don't use the eventHandler but the mouse callback completed with
HomingState++;
if(HomingState>4)
HomingState=0;
I get a step of 1.
Any explanation to this and how can I have a step of 1 using the EventHandler to enable me to coordinate the 2 cockpits ?
Thank for the help
Jean-Pierre
I try to coordinate 2D and 3D panels using custom events.
1) In gauges.h I have declared the new events:
// Third parties can use custom events in this range to communicate between 3D VC's and 2D C++ gauges.
#define THIRD_PARTY_EVENT_ID_MIN 0x00011000
#define THIRD_PARTY_EVENT_ID_MAX 0x0001FFFF
// Third party events
const int KEY_PHI_MODE_INC = 0x11000; //THIRD_PARTY_EVENT_ID_MIN
const int KEY_PHI_MODE_DEC = 0x11001;
2) I have an EventHandler in my sub-gauge :
// GAUGE_KEY_EVENT_HANDLER
static void FSAPI EventHandler(ID32 event, UINT32 evdata, PVOID userdata)
{
switch(event)
{
case KEY_NULL :
break;
case KEY_PHI_MODE_INC:
HomingState++;
if(HomingState>4)
HomingState=0;
break;
case KEY_PHI_MODE_DEC:
HomingState--;
if(HomingState<0)
HomingState=4;
break;
default:
break;
}
}
These 2 events increase/decrease by step of Homingstate (SINT32 variable) a rotactor to set its position (0 to 4)
3) I Have registered and unregistered this EventHandler in mysub-gauge callback :
static void FSAPI gauge_cb( PGAUGEHDR pgauge, int service_id, UINT32 extra_data )
{
switch(service_id)
{
case PANEL_SERVICE_CONNECT_TO_WINDOW:
{
register_key_event_handler((GAUGE_KEY_EVENT_HANDLE R) EventHandler, NULL);
break;
}
case PANEL_SERVICE_PRE_INSTALL:
break;
case PANEL_SERVICE_PRE_UPDATE:
........
break;
case PANEL_SERVICE_DISCONNECT:
{
unregister_key_event_handler((GAUGE_KEY_EVENT_HAND LER) EventHandler, NULL);
break;
}
case PANEL_SERVICE_PRE_KILL:
break;
}
}
4) I call the events with 2 mouse callbacks and update the 3D corresponding element
static BOOL FSAPI switch_inc_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags )
{
trigger_key_event(KEY_PHI_MODE_INC,0);
set_named_variable_value(phi_mode_id,HomingState);
return FALSE;
}
Everything works well except that the increasing step for Homingstate var is 2 and not 1.
If I don't use the eventHandler but the mouse callback completed with
HomingState++;
if(HomingState>4)
HomingState=0;
I get a step of 1.
Any explanation to this and how can I have a step of 1 using the EventHandler to enable me to coordinate the 2 cockpits ?
Thank for the help
Jean-Pierre