Requesting Axis/Button/Key data

#1
Hi folks,

I'm writing a simconnect client and want to turn on and off certain joystick and keyboard inputs. Specifically, I'm masking the Joystick input and using it to control a tug instead of the aircraft, but of course, I only want to mask it while in "tug mode". It works great, but after maybe 5 cycles or so it stops working, and I'm unable to mask to get the joystick info. Is there a built-in limit to how many times you can request and unrequest or mask and unmask, or am I not using the right functions?

This is how I'm turning it on:

SimConnect_MapClientEventToSimEvent(hSimConnect, temp.id);
SimConnect_AddClientEventToNotificationGroup(hSimConnect, temp.id, temp.id, true);

SimConnect_MapInputEventToClientEvent(hSimConnect, temp.id, name, temp.id, 0, SIMCONNECT_UNUSED, SIMCONNECT_UNUSED, true);

SimConnect_SetInputGroupState(hSimConnect, temp.id, SIMCONNECT_STATE_ON);
SimConnect_SetInputGroupPriority(hSimConnect, temp.id, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

/////////////////////
where <temp.id> is a unique serial number and <name> is the axis string name.

Here's how I'm turning it off:

SimConnect_SetInputGroupState(hSimConnect, id, SIMCONNECT_STATE_OFF);
SimConnect_RemoveInputEvent(hSimConnect, id, name);

id == same serial number as used to turn it on


What am I missing? Or is it (hopefully not) that Simconnect just doesn't take kindly to my incessant masking/unmasking?


Any guidance will be very much appreciated,
Farley
 

ddawson

Resource contributor
#2
If it were me, I wouldn't be calling SimConnect_RemoveInputEvent when I shut the thing off.
I would set it all up once and then just call SimConnect_SetInputGroupState to turn the masking on and off.
If you're not doing so, have a look at using the logging capability of SimConnect. You might see something in the log that will be of some help.
 
#3
Hello Mr. Dawson,

Been busy, I apologize. But to update: I implemented your advice, made the IDs static members of the tug class and reused them, calling only SetInputGroupState() when destroying the class and again with the old IDs on subsequent instantiations. It works perfectly and solved my problem completely. Thank you very much sir!

Farley
 
Top