- Messages
- 204
- Country

Hello all.
I got an home built console based on a MJoy16 input card fully working with something like 70 button controls.
These controls transmit button states via wired pushbuttons, toggles switches and rotary encoders.
I've been using this console for quite sometime now, but only via the ingame keyboard mapping interface.
I have to use some extra mapping software to get all controls to work as FS only accepts up to 32 (I wonder why they don't let use all the actual DirectX capabilities well beyond this number).
So, we all know that there are plenty of switches on an aircraft panel which one can access via mouse clicks, as they were left out of the ingame key mapping interface.
So I (finaly) decided to get into simconnect for the purpose of getting all controls I want at the flick of a switch on my console.
I started with the sample scripts provided with the SDK, and I got it working as it should for the pushbuttons. Great.
Now for the toggles and rotaries I got stuck with a problem.
The MJoy16 card translates changes of toggle switch position into momentary joystick button presses, but I noticed each of these presses send 2 values of the event: 1 and 0. What happens when I flick the toggle to switch the beacon lights on, they actualy switch on and off imediatly after.
Here the script I'm using:
I can read the following data event showing the values 1 and 0 each time I flick the switch:
Connected to flight SImulator!
Event toggle beacon lights: 1
Event toggle beacon lights: 0
It should show only 0 as I suppose.
I'd appreciate someone could sort this out.
Thanks in advance.
I got an home built console based on a MJoy16 input card fully working with something like 70 button controls.
These controls transmit button states via wired pushbuttons, toggles switches and rotary encoders.
I've been using this console for quite sometime now, but only via the ingame keyboard mapping interface.
I have to use some extra mapping software to get all controls to work as FS only accepts up to 32 (I wonder why they don't let use all the actual DirectX capabilities well beyond this number).
So, we all know that there are plenty of switches on an aircraft panel which one can access via mouse clicks, as they were left out of the ingame key mapping interface.
So I (finaly) decided to get into simconnect for the purpose of getting all controls I want at the flick of a switch on my console.
I started with the sample scripts provided with the SDK, and I got it working as it should for the pushbuttons. Great.
Now for the toggles and rotaries I got stuck with a problem.
The MJoy16 card translates changes of toggle switch position into momentary joystick button presses, but I noticed each of these presses send 2 values of the event: 1 and 0. What happens when I flick the toggle to switch the beacon lights on, they actualy switch on and off imediatly after.
Here the script I'm using:
Code:
//------------------------------------------------------------------------------
//
// SimConnect Joystick Control Sample
//
// Description:
// button 17 of joystick 1 toggles the beacon lights
//
//------------------------------------------------------------------------------
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#include "SimConnect.h"
int quit = 0;
HANDLE hSimConnect = NULL;
static enum GROUP_ID {
GROUP_0,
};
static enum INPUT_ID {
INPUT_0,
};
static enum EVENT_ID {
EVENT_TOGGLE_BEACON_LIGHTS,
};
void CALLBACK MyDispatchProcJ(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
switch(pData->dwID)
{
case SIMCONNECT_RECV_ID_EVENT:
{
SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
switch(evt->uEventID)
{
case EVENT_TOGGLE_BEACON_LIGHTS:
printf("\nEvent toggle beacon lights: %d", evt->dwData);
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!");
hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_TOGGLE_BEACON_LIGHTS, "TOGGLE_BEACON_LIGHTS");
hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_0, EVENT_TOGGLE_BEACON_LIGHTS);
hr = SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP_0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_0, "joystick:1:button:17", EVENT_TOGGLE_BEACON_LIGHTS);
hr = SimConnect_SetInputGroupState(hSimConnect,INPUT_0, SIMCONNECT_STATE_ON);
while( 0 == quit )
{
SimConnect_CallDispatch(hSimConnect, MyDispatchProcJ, NULL);
Sleep(1);
}
hr = SimConnect_Close(hSimConnect);
}
}
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
testInput();
return 0;
}
I can read the following data event showing the values 1 and 0 each time I flick the switch:
Connected to flight SImulator!
Event toggle beacon lights: 1
Event toggle beacon lights: 0
It should show only 0 as I suppose.
I'd appreciate someone could sort this out.
Thanks in advance.
