• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Joystick Input help.

cheangjc

Resource contributor
Messages
111
Country
singapore
I have tried editing the examples and cut & paste here and there but to no avil. Can someone help me spot the error and correct it for me? I am trying to capture, mask and output it to XML. Any help appreciated.

Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>

#include "SimConnect.h"

int     quit = 0;
HANDLE  hSimConnect = NULL;
int     current = 1;
int sliderpercent = 0;


static enum GROUP_ID {
    INPUT_GROUP
};

static enum DATA_REQUEST_ID {
	REQUEST_APSTATE,
};

static enum INPUT_ID {
    INPUT_SLIDER,
	INPUT_Z
};

static enum EVENT_ID {
    EVENT_A,
 };
            
void CALLBACK MyDispatchProcJ(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
    HRESULT hr;

    switch(pData->dwID)
    {
        case SIMCONNECT_RECV_ID_EVENT:
        {
            SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
			            switch(evt->uEventID) 
						{
										case EVENT_A:
											(long)evt->dwData;
											sliderpercent = dwData;
											break;

										case PANEL_SERVICE_PRE_INITIALIZE:
											register_named_variable ( "FBWELEV99" );
											break;

										case PANEL_SERVICE_PRE_UPDATE:
											sliderpercent = check_named_variable ( "FBWELEV99" ) ;
											break;
					
					default:
                    break;
            }
            break;
        }


        case SIMCONNECT_RECV_ID_QUIT:
        {
            quit = 1;
            break;
        }

        default:
            break;
    }
}





void testInput()
{
    HRESULT hr;

    if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Joystick Input", NULL, 0, 0, 0)))
    {
        printf("\nConnected to Flight Simulator!");   
        
		// Set up a data definition for the throttle control

		


		// Set up some private events
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_A,"AXIS_AILERONS_SET");

		// Add all the private events to a notifcation group
		//hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_0, EVENT_A);
        hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, INPUT_GROUP, EVENT_A,true);

		// Set a high priority for the group
        hr = SimConnect_SetNotificationGroupPriority(hSimConnect, INPUT_GROUP, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);
       
		// Turn all the joystick events off
        //hr = SimConnect_SetInputGroupState(hSimConnect,INPUT_GROUP,  SIMCONNECT_STATE_OFF);
 
 
        while( 0 == quit )
        {
            SimConnect_CallDispatch(hSimConnect, MyDispatchProcJ, NULL);
            Sleep(1);
        } 

        hr = SimConnect_Close(hSimConnect);
	}
}

int __cdecl _tmain(int argc, _TCHAR* argv[])
{
    testInput();
	return 0;
}

Code:
1>------ Build started: Project: Joystick Input, Configuration: Debug Win32 ------
1>  athr.cpp
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(57): error C2065: 'dwData' : undeclared identifier
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(60): error C2065: 'PANEL_SERVICE_PRE_INITIALIZE' : undeclared identifier
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(60): error C2051: case expression not constant
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(61): error C3861: 'register_named_variable': identifier not found
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(64): error C2065: 'PANEL_SERVICE_PRE_UPDATE' : undeclared identifier
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(64): error C2051: case expression not constant
1>d:\program files\microsoft games\microsoft flight simulator x sdk\sdk\core utilities kit\simconnect sdk\samples\joystick input\joystick input\athr.cpp(65): error C3861: 'check_named_variable': identifier not found
 
As a practical matter, if you want to send the output to XML variables, you are going to need to do it from a gauge or stand alone, in-process module.
The functions needed are defined in GAUGES.H and are placed in the gauge's/module's import table. This is why they are showing up in your code as undefined.
The macros PANEL_SERVICE_PRE_INITIALIZE and PANEL_SERVICE_PRE_UPDATE are relevant only to gauge callback functions.

Doug
 
As a practical matter, if you want to send the output to XML variables, you are going to need to do it from a gauge or stand alone, in-process module.
The functions needed are defined in GAUGES.H and are placed in the gauge's/module's import table. This is why they are showing up in your code as undefined.
The macros PANEL_SERVICE_PRE_INITIALIZE and PANEL_SERVICE_PRE_UPDATE are relevant only to gauge callback functions.

Doug

How do i make this code into a gauge? or is this not possible?

Regards,
 
Back
Top