Jump to content
Sign in to follow this  
n4gix

New "Cabin Lights" FX#

Recommended Posts

I noticed while reading the new "Aircraft Container SDK" that there is an entirely new class of FX available: 10=cabin...There is a corresponding entry in the "Electrical" section where you define the bus for "light_cabin."I've checked this out using XML and it works just as expected:The parameter is: (A:Light Cabin,bool)The key event is: TOGGLE_CABIN_LIGHTSPlacing an FX entry in the aircraft cfg like thus:light.0=10, -14.80, -31.2, 0.883441, fx_navredm ,results in the fx_navredm light appearing only when the new "Cabin Lights" switch is used.WONDERFUL! Now we can have a new electrical bus to play with and expand the lighting options more...HOWEVER!I've been unable to replicate this in C thus far. Has anyone a clue what the correct parameter and key_event might be? I've tried many combinations of "guesses," but none have worked thus far... :(


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest JeanLuc_

I'm sure with the panel SDK out these should be a bunch of new C events to support / match the new XML events.Hope this helps!

Share this post


Link to post
Share on other sites

>I'm sure with the panel SDK out these should be a bunch of>new C events to support / match the new XML events.>>Hope this helps!Thanks for the reply, Jean-Luc...Unfortunately, I want to use this in a commercial project, so am trying to avoid XML as much as possible.I noticed that the syntax for the "cabin lights" in XML is the same as "nav lights" in XML, so using that logic tried to replicate the parameter and key_event in C using the similar commands.Do I need to add information to the gaugesFS2002.h file to define these new things?Here is one attempt in C that won't even compile:char cabin_lights_switch_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER cabin_lights_switch_list;PELEMENT_STATIC_IMAGE bg_element =NULL;extern MOUSERECT cabin_lights_switch_mouse_rect[];GAUGE_CALLBACK gaugecall;GAUGE_HEADER_FS700(GAUGE_W, cabin_lights_switch_gauge_name, &cabin_lights_switch_list, cabin_lights_switch_mouse_rect, gaugecall, 0, 0, 0);// Sound declarationstypedef VOID (*TGaugePlaySound)(LPTSTR, LPTSTR,int);typedef VOID (*TGaugeStopSound)(LPTSTR);typedef VOID (*TTerminateSounds)();TGaugePlaySound GaugePlaySound;TGaugeStopSound GaugeStopSound;TTerminateSounds TerminateSounds;HMODULE MGaugeSound;#define GAUGE_CHARSET2 DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT2 "Courier New"#define GAUGE_WEIGHT_DEFAULT2 FW_THINint FIRST_RUN=0;int cabin_lights;MODULE_VAR CABIN_LIGHTSvar = {CABIN_LIGHTS};MODULE_VAR MODULE_VAR_NONEvar = {MODULE_VAR_NONE};void FSAPI gaugecall(PGAUGEHDR pgauge, int service_id, UINT32 extra_data){switch(service_id){case PANEL_SERVICE_PRE_INITIALIZE:if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}bg_element = (PELEMENT_STATIC_IMAGE)pgauge->elements_list[0];GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");break;case PANEL_SERVICE_PRE_KILL:MGaugeSound = GetModuleHandle("GaugeSound");if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");(TerminateSounds)();FreeLibrary(MGaugeSound);break;case PANEL_SERVICE_PRE_UPDATE:MGaugeSound = GetModuleHandle("GaugeSound");if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");lookup_var(&CABIN_LIGHTSvar);lookup_var(&MODULE_VAR_NONEvar);break;case PANEL_SERVICE_PRE_DRAW:if (FIRST_RUN==0) {FIRST_RUN=1;cabin_lights = 0 ; }break;case PANEL_SERVICE_PRE_INSTALL:break;}}BOOL FSAPI mouse_cb0( PPIXPOINT relative_point, FLAGS32 mouse_flags){trigger_key_event (KEY_TOGGLE_CABIN_LIGHTS,0) ; return FALSE;}MOUSE_TOOLTIP_ARGS (GPS_Args)MOUSE_TOOLTIP_ARGS_ENDMOUSE_BEGIN(cabin_lights_switch_mouse_rect,0,0,0)MOUSE_CHILD_FUNCT(2,2,26,59,CURSOR_UPARROW,MOUSE_LEFTSINGLE,mouse_cb0)MOUSE_ENDFAILURE_RECORD fail2[] = {{FAIL_NONE, FAIL_ACTION_NONE}};FAILURE_RECORD fail1[] = {{FAIL_NONE, FAIL_ACTION_NONE}};FLOAT64 FSAPI callback2( PELEMENT_ICON pelement){FLOAT64 rwert=pelement->source_var.var_value.n;return rwert;}MAKE_ICON(Icon2,Rec1,NULL,fail2,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,2,5,CABIN_LIGHTS,callback2,ICON_SWITCH_TYPE_STEP_TO,2,0,0)PELEMENT_HEADER ElementList2[] = {&Icon2.header,NULL};MAKE_STATIC(Static1,Rec0,&ElementList2,fail1,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,0,0)PELEMENT_HEADER cabin_lights_switch_list = &Static1.header;


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest JeanLuc_

This is what I mean! I'm sure when the SDK is out, there will be the C event to match the XML events you have found!events are numbers only. You have to have the number for it, and this is in the .H

Share this post


Link to post
Share on other sites

>This is what I mean! I'm sure when the SDK is out, there will>be the C event to match the XML events you have found!>>events are numbers only. You have to have the number for it,>and this is in the .HAh-ha!OK, it is obvious that MS hasn't changed the event #'s of the existing commands, but not knowing what # they've assigned to this specific command, that would explain why changing the .h file didn't help!In fact, that is why no gauges would compile after .h file mods were made. I replaced the .h file with a copy of the original and all works as before.I guess I'll just have to "suck it up" and use the XML equivalent for the time being... :)Thanks again!


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest bartels

Have you tried to expand the list of key events in the gauges.h past #define KEY_TUG_DISABLE (KEY_ID_MIN + 997)? Maybe there is an event for it. I had a look in the controls.dll where you can extract a list of events (K: for XML directly). For C edit the gauges.h and expand the list of key events with it.Please note: the new events are upside down, so it is preumably:#define KEY_AXIS_FLAPS_SET (KEY_ID_MIN + 998)#define KEY_TOGGLE_MASTER_IGNITION_SWITCH (KEY_ID_MIN + 999)....If the sequencing is correct remains to be tested. So KEY_TOGGLE_CABIN_LIGHTS might be around KEY_ID_MIN+1043:#define KEY_TOGGLE_CABIN_LIGHTS (KEY_ID_MIN + 1043)NOT TESTED! Just a bit of counting.Arne Bartels

Share this post


Link to post
Share on other sites

>If the sequencing is correct remains to be tested. So>KEY_TOGGLE_CABIN_LIGHTS might be around KEY_ID_MIN+1043:>>#define KEY_TOGGLE_CABIN_LIGHTS (KEY_ID_MIN +>1043)>>NOT TESTED! Just a bit of counting.Thanks, Arne. I'll give that a try and let you know. Presumably, I also need to add the parameter to read the status as well:typedef enum GAUGE_TOKEN{ MODULE_VAR_NONE = 0, TICK18, // inc'd at 18hz. used for general purpose timing GROUND_ALTITUDE, // ground level altitude (1/256 meter/unit) CLOCK_HOUR, // local clock time, hours {0..23} CLOCK_MINUTE, // local clock time, minutes {0..59} CLOCK_SECOND, // local clock time, seconds {0..59} ZULU_HOUR, // delta time from GMT ZULU_MINUTE, // delta time from GMT ZULU_DAY, // GMT day of year (1 - 365/366) ZULU_YEAR, // GMT year PANEL_LIGHTS, // TRUE=panel lighting on CABIN_LIGHTS, // TRUE=cabin lighting on


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest bartels

No reading isn't that easy. In principle it would be also just expanding the GAUGE_TOKEN list, but only at the bottom, but the sequence is unknown. Also if you exceed the limit FS will crash. Exceeding KEY_EVENTs is harmless since they simply do nothing, but exceeding the GAUEGE_TOKEN list will crash the FS hard. And inserting the token in the wrong place, e.g. just after PANEL_LIGHTS, all tokens behind that are messed up!Arne Bartels

Share this post


Link to post
Share on other sites
Guest bartels

I just checked how much new tokens are availbale in Fs2004 compared to FS2002: only six! And all are 0, but I also didn't try any of the new keys.Arne Bartels

Share this post


Link to post
Share on other sites

>No reading isn't that easy. In principle it would be also>just expanding the GAUGE_TOKEN list, but only at the bottom,>but the sequence is unknown. Also if you exceed the limit FS>will crash. Exceeding KEY_EVENTs is harmless since they simply>do nothing, but exceeding the GAUEGE_TOKEN list will crash the>FS hard. >And inserting the token in the wrong place, e.g. just after>PANEL_LIGHTS, all tokens behind that are messed up!Thanks again, Arne.I managed to get the gauge to compile, but haven't tested it yet.I did remove the Gauge_Token for CABIN_LIGHTS, but I added it to the bottom of the list.I'm fixing to check it out.If I cannot read the state variable in order to switch the ICONs in the gauge, I'll simply create a custom variable for that purpose... :)The main thing is to get the key_event working!


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Arne!You are a genius!Adding the key_event to 1043 works splendidly!Of course you were also partially correct with regards to the Gauge_Token...I added it to the bottom, but it doesn't DO anything at all...I could have the name wrong, of course.But, the main thing is that I can now go ahead and complete the needed switch! Yeah!Thanks again!


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

For those who don't enjoy typing, here is the complete list of the new key_events, courtesy of Doug Dawson. Simply cut-n-paste into your gauges.h file and enjoy! :)#define KEY_AXIS_FLAPS_SET (KEY_ID_MIN + 998) #define KEY_TOGGLE_MASTER_IGNITION_SWITCH (KEY_ID_MIN + 999) #define KEY_TOGGLE_FEATHER_SWITCHES (KEY_ID_MIN + 1000) #define KEY_TOGGLE_FEATHER_SWITCH_1 (KEY_ID_MIN + 1001) #define KEY_TOGGLE_FEATHER_SWITCH_2 (KEY_ID_MIN + 1002) #define KEY_TOGGLE_FEATHER_SWITCH_3 (KEY_ID_MIN + 1003) #define KEY_TOGGLE_FEATHER_SWITCH_4 (KEY_ID_MIN + 1004) #define KEY_TOGGLE_TAILWHEEL_LOCK (KEY_ID_MIN + 1005) #define KEY_ADF1_WHOLE_INC (KEY_ID_MIN + 1006) #define KEY_ADF1_WHOLE_DEC (KEY_ID_MIN + 1007) #define KEY_ADF2_100_INC (KEY_ID_MIN + 1008) #define KEY_ADF2_10_INC (KEY_ID_MIN + 1009) #define KEY_ADF2_1_INC (KEY_ID_MIN + 1010) #define KEY_ADF2_RADIO_TENTHS_INC (KEY_ID_MIN + 1011) #define KEY_ADF2_100_DEC (KEY_ID_MIN + 1012) #define KEY_ADF2_10_DEC (KEY_ID_MIN + 1013) #define KEY_ADF2_1_DEC (KEY_ID_MIN + 1014) #define KEY_ADF2_RADIO_TENTHS_DEC (KEY_ID_MIN + 1015) #define KEY_ADF2_WHOLE_INC (KEY_ID_MIN + 1016) #define KEY_ADF2_WHOLE_DEC (KEY_ID_MIN + 1017) #define KEY_ADF2_FRACT_INC_CARRY (KEY_ID_MIN + 1018) #define KEY_ADF2_FRACT_DEC_CARRY (KEY_ID_MIN + 1019) #define KEY_ADF2_COMPLETE_SET (KEY_ID_MIN + 1020) #define KEY_RADIO_ADF2_IDENT_DISABLE (KEY_ID_MIN + 1021) #define KEY_RADIO_ADF2_IDENT_ENABLE (KEY_ID_MIN + 1022) #define KEY_RADIO_ADF2_IDENT_TOGGLE (KEY_ID_MIN + 1023) #define KEY_RADIO_ADF2_IDENT_SET (KEY_ID_MIN + 1024) #define KEY_FUEL_SELECTOR_3_OFF (KEY_ID_MIN + 1025) #define KEY_FUEL_SELECTOR_3_ALL (KEY_ID_MIN + 1026) #define KEY_FUEL_SELECTOR_3_LEFT (KEY_ID_MIN + 1027) #define KEY_FUEL_SELECTOR_3_RIGHT (KEY_ID_MIN + 1028) #define KEY_FUEL_SELECTOR_3_LEFT_AUX (KEY_ID_MIN + 1029) #define KEY_FUEL_SELECTOR_3_RIGHT_AUX (KEY_ID_MIN + 1030) #define KEY_FUEL_SELECTOR_3_CENTER (KEY_ID_MIN + 1031) #define KEY_FUEL_SELECTOR_3_SET (KEY_ID_MIN + 1032) #define KEY_FUEL_SELECTOR_4_OFF (KEY_ID_MIN + 1033) #define KEY_FUEL_SELECTOR_4_ALL (KEY_ID_MIN + 1034) #define KEY_FUEL_SELECTOR_4_LEFT (KEY_ID_MIN + 1035) #define KEY_FUEL_SELECTOR_4_RIGHT (KEY_ID_MIN + 1036) #define KEY_FUEL_SELECTOR_4_LEFT_AUX (KEY_ID_MIN + 1037) #define KEY_FUEL_SELECTOR_4_RIGHT_AUX (KEY_ID_MIN + 1038) #define KEY_FUEL_SELECTOR_4_CENTER (KEY_ID_MIN + 1039) #define KEY_FUEL_SELECTOR_4_SET (KEY_ID_MIN + 1040) #define KEY_INDUCTOR_COMPASS_REF_INC (KEY_ID_MIN + 1041) #define KEY_INDUCTOR_COMPASS_REF_DEC (KEY_ID_MIN + 1042) #define KEY_TOGGLE_CABIN_LIGHTS (KEY_ID_MIN + 1043) #define KEY_RESET_G_FORCE_INDICATOR (KEY_ID_MIN + 1044) #define KEY_RESET_MAX_RPM_INDICATOR (KEY_ID_MIN + 1045) #define KEY_MANUAL_FUEL_TRANSFER (KEY_ID_MIN + 1046) #define KEY_AP_PITCH_REF_INC_UP (KEY_ID_MIN + 1047) #define KEY_AP_PITCH_REF_INC_DN (KEY_ID_MIN + 1048) #define KEY_AP_PITCH_REF_SELECT (KEY_ID_MIN + 1049) #define KEY_SIM_RESET (KEY_ID_MIN + 1050) #define KEY_ROTOR_BRAKE (KEY_ID_MIN + 1051) #define KEY_ROTOR_CLUTCH_SWITCH_TOGGLE (KEY_ID_MIN + 1052) #define KEY_ROTOR_CLUTCH_SWITCH_SET (KEY_ID_MIN + 1053) #define KEY_ROTOR_GOV_SWITCH_TOGGLE (KEY_ID_MIN + 1054) #define KEY_ROTOR_GOV_SWITCH_SET (KEY_ID_MIN + 1055) #define KEY_ROTOR_LATERAL_TRIM_INC (KEY_ID_MIN + 1056) #define KEY_ROTOR_LATERAL_TRIM_DEC (KEY_ID_MIN + 1057) #define KEY_ROTOR_LATERAL_TRIM_SET (KEY_ID_MIN + 1058) #define KEY_CROSS_FEED_OPEN (KEY_ID_MIN + 1059) #define KEY_CROSS_FEED_TOGGLE (KEY_ID_MIN + 1060) #define KEY_VIRTUAL_COPILOT_TOGGLE (KEY_ID_MIN + 1061) #define KEY_VIRTUAL_COPILOT_SET (KEY_ID_MIN + 1062) #define KEY_VIRTUAL_COPILOT_ACTION (KEY_ID_MIN + 1063) #define KEY_MIXTURE_SET_BEST (KEY_ID_MIN + 1064) #define KEY_ADD_FUEL_QUANTITY (KEY_ID_MIN + 1065) #define KEY_GPS_POWER_BUTTON (KEY_ID_MIN + 1066) #define KEY_GPS_NEAREST_BUTTON (KEY_ID_MIN + 1068) #define KEY_GPS_OBS_BUTTON (KEY_ID_MIN + 1069) #define KEY_GPS_MSG_BUTTON (KEY_ID_MIN + 1070) #define KEY_GPS_MSG_BUTTON_DOWN (KEY_ID_MIN + 1071) #define KEY_GPS_MSG_BUTTON_UP (KEY_ID_MIN + 1072) #define KEY_GPS_FLIGHTPLAN_BUTTON (KEY_ID_MIN + 1073) #define KEY_GPS_VNAV_BUTTON (KEY_ID_MIN + 1074) #define KEY_GPS_TERRAIN_BUTTON (KEY_ID_MIN + 1075) #define KEY_GPS_PROCEDURE_BUTTON (KEY_ID_MIN + 1076) #define KEY_GPS_SETUP_BUTTON (KEY_ID_MIN + 1077) #define KEY_GPS_ACTIVATE_BUTTON (KEY_ID_MIN + 1078) #define KEY_GPS_ZOOMIN_BUTTON (KEY_ID_MIN + 1079) #define KEY_GPS_ZOOMOUT_BUTTON (KEY_ID_MIN + 1080) #define KEY_GPS_DIRECTTO_BUTTON (KEY_ID_MIN + 1081) #define KEY_GPS_MENU_BUTTON (KEY_ID_MIN + 1082) #define KEY_GPS_CLEAR_BUTTON (KEY_ID_MIN + 1083) #define KEY_GPS_CLEAR_ALL_BUTTON (KEY_ID_MIN + 1084) #define KEY_GPS_CLEAR_BUTTON_DOWN (KEY_ID_MIN + 1085) #define KEY_GPS_CLEAR_BUTTON_UP (KEY_ID_MIN + 1086) #define KEY_GPS_ENTER_BUTTON (KEY_ID_MIN + 1087) #define KEY_GPS_CURSOR_BUTTON (KEY_ID_MIN + 1088) #define KEY_GPS_GROUP_KNOB_INC (KEY_ID_MIN + 1089) #define KEY_GPS_GROUP_KNOB_DEC (KEY_ID_MIN + 1090) #define KEY_GPS_PAGE_KNOB_INC (KEY_ID_MIN + 1091) #define KEY_GPS_PAGE_KNOB_DEC (KEY_ID_MIN + 1092) #define KEY_GPS_BUTTON1 (KEY_ID_MIN + 1093) #define KEY_GPS_BUTTON2 (KEY_ID_MIN + 1094) #define KEY_GPS_BUTTON3 (KEY_ID_MIN + 1095) #define KEY_GPS_BUTTON4 (KEY_ID_MIN + 1096) #define KEY_GPS_BUTTON5 (KEY_ID_MIN + 1097) #define KEY_THROTTLE_DECR_SMALL (KEY_ID_MIN + 1098) #define KEY_THROTTLE1_DECR_SMALL (KEY_ID_MIN + 1099) #define KEY_THROTTLE2_DECR_SMALL (KEY_ID_MIN + 1100) #define KEY_THROTTLE3_DECR_SMALL (KEY_ID_MIN + 1101) #define KEY_THROTTLE4_DECR_SMALL (KEY_ID_MIN + 1102) #define KEY_PROP_PITCH_DECR_SMALL (KEY_ID_MIN + 1103) #define KEY_PROP_PITCH1_DECR_SMALL (KEY_ID_MIN + 1104) #define KEY_PROP_PITCH2_DECR_SMALL (KEY_ID_MIN + 1105) #define KEY_PROP_PITCH3_DECR_SMALL (KEY_ID_MIN + 1106) #define KEY_PROP_PITCH4_DECR_SMALL (KEY_ID_MIN + 1107) #define KEY_MIXTURE_DECR_SMALL (KEY_ID_MIN + 1108) #define KEY_MIXTURE1_DECR_SMALL (KEY_ID_MIN + 1109) #define KEY_MIXTURE2_DECR_SMALL (KEY_ID_MIN + 1110) #define KEY_MIXTURE3_DECR_SMALL (KEY_ID_MIN + 1111) #define KEY_MIXTURE4_DECR_SMALL (KEY_ID_MIN + 1112)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...