From X-Plane SDK
Revision as of 14:25, 26 December 2012 by Sbarbour (Talk | contribs)

Jump to: navigation, search

	TestEnums Example
	Written by Sandy Barbour - 23/04/2004
	This examples shows how to send key and joystick commands

#include "XPLMPlugin.h"
#include "XPLMUtilities.h"
#include "XPLMProcessing.h"
#include "XPLMMenus.h"
#include "XPLMGraphics.h"
#include "XPLMPlanes.h"
#include "XPLMDataAccess.h"
#include "XPWidgets.h"
#include "XPStandardWidgets.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if IBM
#include <windows.h>

#define MAX_VIEW_ENUMS 21
#define MAX_AP_STATES 12

static int MenuItem1, KeyCommandLinePosition, JoystickCommandLinePosition, ViewEnumsLinePosition, AutopilotStateLinePosition;

// Widgets
static XPWidgetID TestEnumsWidget = NULL, TestEnumsWindow = NULL;
static XPWidgetID SendKeyCommandButton = NULL, KeyCommandText = NULL, KeyCommandIDText = NULL, KeyUpArrow = NULL, KeyDownArrow = NULL;
static XPWidgetID SendJoystickCommandButtonPress = NULL, SendJoystickCommandButtonRelease = NULL, JoystickCommandText = NULL, JoystickCommandIDText = NULL, JoystickUpArrow = NULL, JoystickDownArrow = NULL;
static XPWidgetID SendViewEnumsButton = NULL, ViewEnumsText = NULL, ViewEnumsIDText = NULL, ViewEnumsUpArrow = NULL, ViewEnumsDownArrow = NULL;
static XPWidgetID SendAutopilotStateButton = NULL, AutopilotStateText = NULL, AutopilotStateIDText = NULL, AutopilotStateUpArrow = NULL, AutopilotStateDownArrow = NULL;
static XPWidgetID V6CheckBox = {NULL};

static XPLMDataRef gViewType = NULL, gAutopilotState = NULL;

typedef struct _MESSAGE_STRUCT
	char MessageText[80];
	int MessageEnum;

typedef struct _MESSAGE_STRUCT2
	char MessageText[80];
	int MessageEnumV6;
	int MessageEnumV7;

	{"Pause Sim", xplm_key_pause},
	{"Reverse Thrust", xplm_key_revthrust},
	{"Jettison", xplm_key_jettison},
    {"Brakes Regular", xplm_key_brakesreg},
    {"Brakes Max", xplm_key_brakesmax},
	{"Toggle Gear", xplm_key_gear},
    {"Time Down", xplm_key_timedn},
    {"Time Up", xplm_key_timeup},
    {"FADEC", xplm_key_fadec},
    {"AP Disconnect", xplm_key_otto_dis},
    {"AP Auto Throttle", xplm_key_otto_atr},
    {"AP Air Speed", xplm_key_otto_asi},
    {"AP Heading", xplm_key_otto_hdg},
    {"AP GPS", xplm_key_otto_gps},
    {"AP Wing Leveler", xplm_key_otto_lev},
    {"AP HNAV", xplm_key_otto_hnav},
    {"AP Altitude", xplm_key_otto_alt},
    {"AP Vertical Speed", xplm_key_otto_vvi},
    {"AP VNAV", xplm_key_otto_vnav},
    {"AP NAV1", xplm_key_otto_nav1},
    {"AP NAV2", xplm_key_otto_nav2},
    {"TARG Down", xplm_key_targ_dn},
    {"TARG Up", xplm_key_targ_up},
    {"Heading Down", xplm_key_hdgdn},
    {"Heading Up", xplm_key_hdgup},
    {"Barometer Down", xplm_key_barodn},
    {"Barometer Up", xplm_key_baroup},
    {"OBS1 Down", xplm_key_obs1dn},
    {"OBS1 Up", xplm_key_obs1up},
    {"OBS2 Down", xplm_key_obs2dn},
    {"OBS2 Up", xplm_key_obs2up},
    {"COM1 1", xplm_key_com1_1},
    {"COM1 2", xplm_key_com1_2},
	{"COM1 3", xplm_key_com1_3},
    {"COM1 4", xplm_key_com1_4},
    {"NAV1 1", xplm_key_nav1_1},
    {"NAV1 2", xplm_key_nav1_2},
    {"NAV1 3", xplm_key_nav1_3},
    {"NAV1 4", xplm_key_nav1_4},
    {"COM2 1", xplm_key_com2_1},
    {"COM2 2", xplm_key_com2_2},
	{"COM2 3", xplm_key_com2_3},
	{"COM2 4", xplm_key_com2_4},
	{"NAV2 1", xplm_key_nav2_1},
	{"NAV2 2", xplm_key_nav2_2},
	{"NAV2 3", xplm_key_nav2_3},
	{"NAV2 4", xplm_key_nav2_4},
	{"ADF 1", xplm_key_adf_1},
	{"ADF 2", xplm_key_adf_2},
	{"ADF 3", xplm_key_adf_3},
	{"ADF 4", xplm_key_adf_4},
	{"ADF 5", xplm_key_adf_5},
	{"ADF 6", xplm_key_adf_6},
	{"XPDR 1", xplm_key_transpon_1},
	{"XPDR 2", xplm_key_transpon_2},
	{"XPDR 3", xplm_key_transpon_3},
	{"XPDR 4", xplm_key_transpon_4},
	{"XPDR 5", xplm_key_transpon_5},
	{"XPDR 6", xplm_key_transpon_6},
	{"XPDR 7", xplm_key_transpon_7},
	{"XPDR 8", xplm_key_transpon_8},
	{"Flaps Up", xplm_key_flapsup},
	{"Flaps Down", xplm_key_flapsdn},
	{"Carb Heat Off", xplm_key_cheatoff},
	{"Carb Heat On", xplm_key_cheaton},
	{"Speed Brake Off", xplm_key_sbrkoff},
	{"Speed Brake On", xplm_key_sbrkon},
	{"Aileron Trim Left", xplm_key_ailtrimL},
	{"Aileron Trim Right", xplm_key_ailtrimR},
	{"Rudder Trim Left", xplm_key_rudtrimL},
	{"Rudder Trim Right", xplm_key_rudtrimR},
	{"Elevator Trim Down", xplm_key_elvtrimD},
	{"Elevator Trim Up", xplm_key_elvtrimU},
	{"Forward", xplm_key_forward},
	{"Down", xplm_key_down},
	{"Left", xplm_key_left},
	{"Right", xplm_key_right},
	{"Back", xplm_key_back},
	{"Tower", xplm_key_tower},
	{"Runway", xplm_key_runway},
	{"Chase", xplm_key_chase},
	{"Free 1", xplm_key_free1},
	{"Free 2", xplm_key_free2},
	{"Spot", xplm_key_spot},
	{"Full Screen 1", xplm_key_fullscrn1},
	{"Full Screen 2", xplm_key_fullscrn2},
	{"Transparent", xplm_key_tanspan},
	{"Smoke", xplm_key_smoke},
	{"Map", xplm_key_map},
	{"Zoom In", xplm_key_zoomin},
	{"Zoom Out", xplm_key_zoomout},
	{"Cycle Dump", xplm_key_cycledump},
	{"Replay", xplm_key_replay},
	{"Transponder ID", xplm_key_tranID},
	{"Max", xplm_key_max}

	{"Nothing", xplm_joy_nothing},
	{"Start All", xplm_joy_start_all},
	{"Start 0", xplm_joy_start_0},
	{"Start 1", xplm_joy_start_1},
	{"Start 2", xplm_joy_start_2},
	{"Start 3", xplm_joy_start_3},
	{"Start 4", xplm_joy_start_4},
	{"Start 5", xplm_joy_start_5},
	{"Start 6", xplm_joy_start_6},
	{"Start 7", xplm_joy_start_7},
	{"Throttle Up", xplm_joy_throt_up},
	{"Throttle Down", xplm_joy_throt_dn},
	{"Prop Up", xplm_joy_prop_up},
	{"Prop Down", xplm_joy_prop_dn},
	{"Mixture Up", xplm_joy_mixt_up},
	{"mixture Down", xplm_joy_mixt_dn},
	{"Carb Toggle", xplm_joy_carb_tog},
	{"Carb On", xplm_joy_carb_on},
	{"Carb Off", xplm_joy_carb_off},
	{"Trim Elevator", xplm_joy_trev},
	{"Trim Up", xplm_joy_trm_up},
	{"Trim Down", xplm_joy_trm_dn},
	{"Rotor Trim Up", xplm_joy_rot_trm_up},
	{"Rotor Trim Down", xplm_joy_rot_trm_dn},
	{"Rudder Left", xplm_joy_rud_lft},
	{"Rudder Centre", xplm_joy_rud_cntr},
	{"Rudder Right", xplm_joy_rud_rgt},
	{"Aileron Left", xplm_joy_ail_lft},
	{"Aileron Centre", xplm_joy_ail_cntr},
	{"Aileron Right", xplm_joy_ail_rgt},
	{"B Rudder Left", xplm_joy_B_rud_lft},
	{"B Rudder Right", xplm_joy_B_rud_rgt},
	{"Look Up", xplm_joy_look_up},
	{"Look Down", xplm_joy_look_dn},
	{"Look Left", xplm_joy_look_lft},
	{"Look Right", xplm_joy_look_rgt},
	{"Glance Left", xplm_joy_glance_l},
	{"Glance Right", xplm_joy_glance_r},
	{"View Forward No HUD", xplm_joy_v_fnh},
	{"View Forward HUD", xplm_joy_v_fwh},
	{"View Transparent", xplm_joy_v_tra},
	{"View Tower", xplm_joy_v_twr},
	{"View Runway", xplm_joy_v_run},
   	{"View Chase", xplm_joy_v_cha},
	{"View Free 1", xplm_joy_v_fr1},
	{"View Free 2", xplm_joy_v_fr2},
    {"View Spo", xplm_joy_v_spo},
	{"Flaps Up", xplm_joy_flapsup},
	{"Flaps Down", xplm_joy_flapsdn},
	{"Vector Sweep Forward", xplm_joy_vctswpfwd},
	{"Vector Sweep Aft", xplm_joy_vctswpaft},
	{"Gear Toggle", xplm_joy_gear_tog},
	{"Gear Up", xplm_joy_gear_up},
	{"Gear Down", xplm_joy_gear_down},
	{"Left Brake", xplm_joy_lft_brake},
	{"Right Brake", xplm_joy_rgt_brake},
	{"Brakes Regular", xplm_joy_brakesREG},
	{"Brakes Max", xplm_joy_brakesMAX},
	{"Speed Brake", xplm_joy_speedbrake},
	{"AP Disconnect", xplm_joy_ott_dis},
	{"AP Auto Throttle", xplm_joy_ott_atr},
	{"AP Airspeed", xplm_joy_ott_asi},
	{"AP Heading", xplm_joy_ott_hdg},
	{"AP Altitude", xplm_joy_ott_alt},
	{"AP Vertical Speed", xplm_joy_ott_vvi},
	{"Timer Start", xplm_joy_tim_start},
	{"Timer Reset", xplm_joy_tim_reset},
	{"ECAM Up", xplm_joy_ecam_up},
	{"ECAM Down", xplm_joy_ecam_dn},
	{"FADEC", xplm_joy_fadec},
	{"Yaw Damper", xplm_joy_yaw_damp},
	{"Arificial Stability", xplm_joy_art_stab},
	{"Chute", xplm_joy_chute},
	{"JATO", xplm_joy_JATO},
	{"Arrester", xplm_joy_arrest},
	{"Jettison", xplm_joy_jettison},
	{"Fuel Dump", xplm_joy_fuel_dump},
	{"Puff Smoke", xplm_joy_puffsmoke},
	{"Pre-Rotate", xplm_joy_prerotate},
	{"UL Pre-Rotate", xplm_joy_UL_prerot},
	{"UL Collect", xplm_joy_UL_collec},
	{"TOGA", xplm_joy_TOGA},
	{"Shutdown", xplm_joy_shutdown},
	{"Contact ATC", xplm_joy_con_atc},
	{"Fail Now", xplm_joy_fail_now},
	{"Pause", xplm_joy_pause},
	{"Rocket Up", xplm_joy_rock_up},
	{"Rocket Down", xplm_joy_rock_dn},
	{"Rocket Left", xplm_joy_rock_lft},
	{"Rocket Right", xplm_joy_rock_rgt},
	{"Rocket Forward", xplm_joy_rock_for},
	{"Rocket Aft", xplm_joy_rock_aft},
	{"Idle HILO", xplm_joy_idle_hilo},
	{"Landing Lights", xplm_joy_lanlights},
	{"Max", xplm_joy_max}