Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Mag Issue

Featured Replies

Hi All, I have been developing a panel for a C152, and am having a small problem. All the switches, trim and throttle work fine. The only thing I can't get working is the mag switch. The following is my code.

 </div>	  <pre class="alt2" dir="ltr" style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 2114px; text-align: left;">using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.FlightSimulator.SimConnect; using System.Runtime.InteropServices; using System.IO.Ports; using VolumeControl.Library.Constants; using VolumeControl.Library.Structs; using VolumeControl.Library.Win32;  namespace WindowsFormsApplication1 {	 public partial class Form1 : Form	 {		 enum GROUP_PRIORITIES : uint		 {			 SIMCONNECT_GROUP_PRIORITY_HIGHEST = 1,			 SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE = 10000000,			 SIMCONNECT_GROUP_PRIORITY_STANDARD = 1900000000,			 SIMCONNECT_GROUP_PRIORITY_DEFAULT = 2000000000,			 SIMCONNECT_GROUP_PRIORITY_LOWEST = 4000000000		 } 		 enum Event		 {   			 MAGNETO1_OFF,			 MAGNETO1_RIGHT,			 MAGNETO1_LEFT,			 MAGNETO1_BOTH,			 MAGNETO1_START		 }																		   		 SimConnect simconnect; 		 const int WM_USER_SIMCONNECT = 0x0402; 		 public Form1()		 {			 InitializeComponent();			 init();		 } 		 private void init()		 {			 /////////////////Connect to SimConnect server			 try			 {				 simconnect = new SimConnect("SimConnect Tutorial", this.Handle, WM_USER_SIMCONNECT, null, 0); 				 simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);				 simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit); 				 simconnect.MapClientEventToSimEvent(Event.MAGNETO1_OFF, "MAGNETO1_OFF");				 simconnect.MapClientEventToSimEvent(Event.MAGNETO1_RIGHT, "MAGNETO1_RIGHT");				 simconnect.MapClientEventToSimEvent(Event.MAGNETO1_LEFT, "MAGNETO1_LEFT");				 simconnect.MapClientEventToSimEvent(Event.MAGNETO1_BOTH, "MAGNETO1_BOTH");				 simconnect.MapClientEventToSimEvent(Event.MAGNETO1_START, "MAGNETO1_START");    				 textBox2.Text = "Connected";			 } 			 catch (COMException)			 {				 textBox2.Text = "Unable to Connect";			 }			 /////////////////////////////////////////////		 }  		 void simconnect_OnRecvOpen(SimConnect sender, SIMCONNECT_RECV_OPEN data)		 {			 textBox2.Text = "Connected to SimConnect";		 }  		 void simconnect_OnRecvQuit(SimConnect sender, SIMCONNECT_RECV data)		 {			 simconnect.Dispose();			 Application.Exit(); 		 }  		 protected override void DefWndProc(ref Message m)		 {			 if (m.Msg == WM_USER_SIMCONNECT)			 {				 if (simconnect != null)				 {					 simconnect.ReceiveMessage();				 }			 }			 else			 {				 base.DefWndProc(ref m);			 }		 }  		 private void button1_Click(object sender, EventArgs e)		 {			 simconnect.TransmitClientEvent(0, Event.MAGNETO1_OFF, 0, GROUP_PRIORITIES.SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);		 } 		 private void button2_Click(object sender, EventArgs e)		 {			 simconnect.TransmitClientEvent(0, Event.MAGNETO1_RIGHT, 0, GROUP_PRIORITIES.SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);		 } 		 private void button3_Click(object sender, EventArgs e)		 {			 simconnect.TransmitClientEvent(0, Event.MAGNETO1_LEFT, 0, GROUP_PRIORITIES.SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);		 } 		 private void button4_Click(object sender, EventArgs e)		 {			 simconnect.TransmitClientEvent(0, Event.MAGNETO1_BOTH, 0, GROUP_PRIORITIES.SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);		 } 		 private void button5_Click(object sender, EventArgs e)		 {			 simconnect.TransmitClientEvent(0, Event.MAGNETO1_START, 0, GROUP_PRIORITIES.SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);		 } 		} }</pre>  </div>

The problem I am having is that when I click the 3rd button(MAGNETO1_LEFT), the mag in the simulator will go to both. If I click it again, it will select right in the sim. All the other positions work fine. I just don't understand what is going on here. Can anyone see what I am doing wrong? Thanks Mark

  • Commercial Member
The problem I am having is that when I click the 3rd button(MAGNETO1_LEFT), the mag in the simulator will go to both. If I click it again, it will select right in the sim. All the other positions work fine. I just don't understand what is going on here. Can anyone see what I am doing wrong?
Nothing. I can confirm that it is an FSX bug.I use the MAGNETO1_SET event successfully -- parameters 0 - 4 do correspond correctly with the Off, Right, Left, Both, Start positions, respectively.RegardsPete

Win10: 22H2 19045.2728
CPU: 9900KS at 5.5GHz
Memory: 32Gb at 3800 MHz.
GPU:  RTX 24Gb Titan
2 x 2160p projectors at 25Hz onto 200 FOV curved screen

Thanks for that, I was starting to go mad.ThanksMark

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.