Jump to content

Highest Reputation Content

#468207 Lua programs to access your Saitek Radio, Switch and Multi panel

Posted by kamarad on 19 May 2014 - 08:22 PM



This post explains how you can use a LUA routine to access the status of the buttons/switches/selectors/gear and flaps lever and trim wheel (herewith named collectively as Buttons) on 3 Saitek panels using FSUIPC and Linda. The first section presents a quick instruction to start gathering information  based on lua program attached to this post. The second section gives a simple example of a Lua program that access the Saitek panel buttons status and select specific FSX/P3D actions accordingly. The third section goes more into the details about how this LUA programs was made.


You need a registered version of FSUIPC for this to work.


Section 1 – Quick Start


Download and install the relevant LUA routines;


Attached to this post are 3 Lua programs corresponding to the 3 Saitek panels. You just need to install the ones corresponding to the panel you own.  The 3 Lua programs are:


-          HIDRadio.lua

-          HIDMulti.lua

-          HIDSwitch.lua


Note; I have renamed the 3 programs with a .txt exension for upload as the system doesnt allow to upload .lua files. You will need to change the extension back to .lua before using them.


To install them, just drop the ones corresponding to the panel you own into the “module” directory of FSX/P3D.


Automatic start of the LUA programs


The LUA programs selected above must run in permanence to scan the status of the buttons and map (copy) this information into specific address of the FSUIPC offsets. To inform FSUIPC that those programs must start and run continuously, it is necessary to add the following lines to the FSUIPC.ini files (located in the module directory of FSX/P3D).



1=lua HIDRadio

2=lua HIDMulti

3=lua HIDSwitch


On the next start-up of FSUIPC, the Lua program will start to scan the status of the buttons and selector on Saitek panels.


Checking with FSUIPC logging facility that the Lua programs are in place and operating


FSUIPC has a built in logging facility that can be useful to check the proper operation of the Lua programs and the correct mapping of switches to the offset address.


Go to the FSUIPC Logging tab and on the right part of the screen, enter the following information:


Offset   Type of data       Remark

3358       U32                        Saitek Radio panel offset address

335C      U32                        Saitek Multi Panel offset address

3360       U32                        Saitek Switches Panel offset address


Then click on “FS window” and you should have a green message on the top left of your screen. Move some selectors or push buttons on each of your panels and see if the values on screen change according to the position of the buttons. An annex at the end of this post gives the value of each button.


Note1  : The knob just send a short pulse so the number on screen will just change very rapidly and come back to the value prior to moving the knob when you stop moving it.

Note 2: The buttons just change status while they are pressed, they doesn’t indicate the status of the corresponding function. Ex: the Autopilot button will just send a ON status when you press the button. So this is not intended to test if functions like the AP are engaged or not. It’s just to test the instantaneous position of the hardware buttons.


Make sure you have version 4.934 as the previous one has a problem that killed lua programs on start-up and caused me a couple of evening of head scratching... 4.934 solved this as soon as I installed it.


Accessing the information from within a LUA program in Linda


Now everything is in place and you have the possibility to access the information on your panel switch.


For simple assignation of a single button, you usually doesn’t need complex programming as FSX, Spad or Linda menu all allow you to directly select FSX/P3D commands. On the other hand, if you want to combine the status from different buttons to trigger a specific FSX/P3D action, then you need to use a Lua program (you can also use FSUIPC conditional button programming but Lua is more flexible).


Using Linda, it is possible to assign user created Lua program to a button so the program is called when the button is push (or a switch is move to the “on” position or a selector is put in a specific position). The Lua program allows you to test the status of others buttons and makes your program act accordingly to send the proper FSX/P3D command.


In Linda, you can create individual LUA program module (a module can contain several Lua program) for each aircraft. Linda includes also a text editor that makes creation of Lua program easy. Some functions in the Lua library allow reading specific address in FSUIPC offsets. Each address that will be assigned to the 3 Saitek panels covered here will contain between 18 to 20 bits of useful information (not considering the LED display) that correspond to all the buttons, switches, selectors and gear and flaps lever of the panel. The switches panel for instance contains 20 bits of information that you can test. The address to use in order to read each panel information are:  


0x3358 = Radio panel

0x335C = Multi panel

0x3360 = Switch panel


Note : You can assign other address if those one are already used for other purposed on your setup. You will need to modify the HIDxxx.lua program that correspond to the device you want to change.


Note: The "0x" in the adress above just means that its written in hexadecimal notation. You will need to include the 0x within Lua program otherwise it will consider that the address provided is decimal. Please note that in the FSUIPC logging page, you don’t need to include the 0x as this page always consider that the value entered is hexadecimal.


There are two main functions within Lua programs that can help you to read buttons status.


First, the following Lua program line read all the bytes of information from the Saitek Radio panel and put it in a variable named “pos”.


pos = ipc.readUB(0x3358)


But the value returned is not quite useful by itself as it represents the cumulative sum of all the individual bits for switches that are in the “on” position resulting in a large number of possible values. You then need to isolate the value that you are specifically interested by using the following function (here represented in a separate line).


pos = logic.And(pos,mask).


Here mask correspond to the specific value (or sum of values) you are interested in. For instance, if you are interested to test if the position of the magneto switch is at the “right” position on the Saitek switch panel, then the value for the mask is 32768 (see annex for all possible values) and the Lua program line becomes


Pos = logic.And(pos,32768)


Section 2 : Example for the Duke piston or Douglas C-47 Magneto selector


In the Duke Piston from Real air (and Douglas C-47 from Manfred Jahn), the magneto animation in the VC are reversed compared to the Saitek switch magneto button for the “left” and “right” position which create a weird jump in the VC while you move the magneto selector on your Saitek panel.

-          Duke Piston/Douglas C-47 VC magneto selector order: Off – Left – Right – Both – Start

-          Saitek Switch panel magneto selector order: Off – Right – Left – Both - Start


So the objective is to program a function in a Linda module that will reverse the operation of the left and right magneto position between the Saitek panel and the VC. In addition, we want to test the position of the upper mode button for the Saitek radio panel to determine if we want to operate the motor 1 or 2. Spad has a built-in functionality that allows using several switches (ex: Aternator, fuel pump, cowl, de ice)  to act on motor 1 or on motor 2 according to the position of the top selector on the Radio panel and we want to replicate this functionality here.


First you need to create a module for your targeted aircraft if it’s not already existing. See Linda documentation to do this.


Then you need to copy the following program (or use the Magneto.txt file provided) into the aircraft module using Linda editor screen. Again, refer to Linda documentation to see how to open the editor.


The title between double hash characters is recognized by Linda as a heading separator for functions. It makes easier to identify function you have created.

Comments (text preceded by --) in the program below provide detailed comments for each steps.


-- ## Magneto ##


Function MagLeftVC ()


-- This function handle the reversal of the magneto in the VC panel compared to the Saitek selector.

-- It is activated when the selector on the Saitek switch panel will be put at the left position. 

-- It will result in positionning the VC magneto selector to the "right" position.

-- The Saitek Radio top left selector at position COM1 means that the left engine is considered. If the selector is at the COM2 position, then the right engine will be treated.


-- The information about the radio panel status is at offset 0x3358

-- reading the offset to get all Radio panel switches current status


pos = ipc.readUB(0x3358)


-- The next line of lua code will isolate the bits of information we are interested in

-- mask = 1 would be usefull ot test if the top left selector at the COM1 position

-- mask = 2 would be appropriate to test if the top left selector at the COM2 position

-- Mask = 3 accept both COM1 and COM2 and will return either 1 or 2 as the selector

--   can be only in one of the two positions at a given time.

--   If the selector is not at COM1 or COM2, then the logic.And function will return zero and no action will be done.


pos = logic.And(pos,3)


-- the next group of lines will send the command to put the magneto for left or right motor in the right position in the VC.

-- 66400 is the Magneto1_set command for FSX/P3D

-- 66401 is the Magneto2_set command for FSX/P3D

-- The parameter 2 is for the “right” position of the magneto


if pos ==1 then ipc.control(66400,2)

else if pos ==2 then ipc.control(66401,2)




Function MagRightVC ()

-- same approach as for the left mag function, without comments here

pos = ipc.readUB(0x3358)

pos = logic.And(pos,3)

if pos ==1 then ipc.control(66400,1)

elseif pos ==2 then ipc.control(66401,1)




Section 3 – Nut and Bolts.


This section provides some additional explanation on how the HIDRadio.lua program was created from the HIDDemo.lua program provided by Peter.


Step 1: Obtain HIDDemo.lua


We need to have a Lua program running continuously to scan the Saitek panel switch status then map this information in FSUIPC offset. The offset can then be read from a Lua program in a Linda module for an aircraft. Peter Dowson provided an example of a Lua program that scan HID device like the Saitek panels and write the information on offset. We just want to use his demo and modify it a bit.


The HidDemo.lua program is available in the complete install of FSUIPC4.


Or you can download the latest HidDemo.lua  example from : http://forum.simflig...and-wideclient/


Step 2: Create HIDRadio.lua


Make a copy of HIDDemo.lua and name it HIDRadio.lua (we will give only one example herewith but the same approach works for the switch and the multi panel also).


Step 3 – Adjust HID device identification


At the beginning of the HIDDemo.lua program, there is two lines that identify the Saitek panel (HID device) you want to communicate with. You have to insert the hexadecimal code for the vendor and for the product.  For instance the lines for the Saitek radio panel are:

-- Saitek Radio panel

Vendor = 0x06A3

Product = 0x0D05


If you dont know the HID device codes, there is a utility provided by Peter Dowson called HIDscanner.exe that gives a report about all devices connected to your PC and their vendor rand product codes.


I already run this utility to find the relevant information of the 3 following Saitek Products.


Radio Panel :

Vendor = 0x06A3

Product = 0x0D05

Multi Panel :

Vendor =0x06A3

Product = 0x0D06

Switch Panel :

Vendor =0x06A3

Product = 0x0D67


The HIDScanner.exe utility is available at the same link provided above on Peter support page.


Step 4 : Change the size and destination of information blocks


In HIDDemo.exe, you will find a loop of instruction toward the end of the program that read the status of the buttons on your HID device and copy it to a specific offset.  The loop is initially programmed for reading 8 blocks composed of 4 Bytes of information. For the Saitek panel switches, you only need to do it once as all information fit into a double world (32 bits of information).  So I cleaned the iteration loop (from 1 to 8 and adjusted the HIDDemo.lua program to do a single read of a 32 bits of information that is sufficient for the Saitek panels.


Next, you need to select the destination for the button information in the FSUIPC offset table. There is an ipc.writeUD instruction in the HIDDemo.lua program that was modified to correspond to an offset that was used for mapping.


The possible offset for the 9 contiguous blocks of 4 bytes (32 bits of information) are: 0x3340, 0x3344, 0x3348, 0x334C, 0x3350, 0x3354, 0x3358, 0x335C, 0x3360. See the “FSUIPC4 Offset Status.pdf” document provided with FSUIPC documentation. The Saitek version of HIDDemo.lua use the 3 last virtual joystick addresses so Joystick 71,72 and 73 located at 0x3358, 0x335C and 0x3360 respectively.


Step 5 : Install your newly created Lua program


Just copy them it in the “module” directory of FSX or P3D. If you have started with the quick start portion of this document, you have already done this.


Step 6 : Automatic startup of HIDRadio.lua


To start automatically your Lua program add the following lines in FSUIPC.ini. If you have applied the quick start instruction, its already done.



1=lua HidRadio


Step 7 : Create custom lua program


See the example provided for the Duke above.


Annex: Saitek panels reference of  “buttons” value


Saitek Radio Panel (20 bit of information + 2 bit unused)


Top left mode selector

1= Com1

2= Com2             

4= Nav1

8= Nav2

16= Adf

32= Dme

64= Xpdr

Bottom Left mode selector

128= Com1

256= Com2

512= Nav1

1024= Nav2

2048= Adf

4096= Dme

8192= Xpdr

16384 = Top right ACT/STB button

32768 = Bottom right ACT/STB button

65536 = Clockwise turn of the top knob

131072 (2E17)=Counter-clockwise turn of the top knob

1048576 (2E20) = Clockwise turn of the bottom knob

2097152 (2E21) = Counter-clockwise turn of the bottom knob


Saitek Multi Panel (20 bit of information)


Selector button

1= Alt

2= VS

4= IAS



32= Clockwise rotation of knob

64= Counter clockwise rotation of knob

128= AP button

256= HDG button

512= NAV button

1024= IAS button

2048= ALT button

4096= VS button

8192= APR button

16384= REV button

32768= Auto Throttle switch ON

65536= Flaps up (2^16)

131072= Flaps down (2^17)

262144= Elevator Trim Pitch up (2^18)

524288= Elevator Trim Pitch Down (2^19)


Saitek Switch panel (20 bit of information)


Note: The minimum value returned corresponds to the position of the landing gear handle plus the position of the magneto knob. 262144 is returned if the gear lever is UP and 524288 if the gear lever is DOWN.


1= Battery

2= Alternator

4= Avionic

8= Pump

16= De Ice

32= Pitot heat

64= Cowl

128= Panel

256= Beacon

512= Nav

1024= Strobe

2048= Taxi

4096= Landing


Magneto selector

8192= Off magneto

16384= Left Magneto

32768= Right Magneto

65536= Both Magneto

131072= Start Magneto

Landing gear lever

262144= Landing gear Up

524288 (2E19)= Landing Gear Down

Attached Files

  • 2

#451010 New FSUIPC4 registrations for 2013 need version 4.859n or later!

Posted by Pete Dowson on 14 January 2013 - 05:26 PM

Oops. Same date limit was in FSUIPC4 too!

  • 2

#450631 FS Commander won't let me load flightplans?

Posted by JerryJet on 03 January 2013 - 12:42 PM

So it can save flightplans in those formats, but can't then reload those very same flightplans unless they exist in FSC's format? And I paid $40 for this??? Can I just say how stupid that is?

Flightsim Commander is released as shareware letting you evaluate the program to see if it suits your needs. You can also read the exhaustive manual which explains how and why FSC saves flightplans. Numerous different planes/companies can be chosen when saving, but one is always checked and can never be unchecked. I'll let you figure out what that means.

  • 2

#490021 Best way to handle FSUIPC errors on Sim crash?

Posted by Paul Henty on 29 March 2016 - 01:40 PM

EDIT: I cannot see the attachment?



I attached the Beta instead of the RC1 version. I have to swap it. Should be there now - make sure you have the RC1 version.



  • 1

#489880 Simconnect Error after update to P3D v3.2.3.1679

Posted by flying-w on 23 March 2016 - 08:19 AM

Reported to Lockheed Martin, let's hope they'll take a look at it:




  • 1

#489736 New window capture feature from FSUIPC

Posted by Chrilith on 18 March 2016 - 10:06 AM



A new Passerelle version is coming with a window capture feature. Passerelle is a module to control Saitek devices that can be used with the FSUIPC Lua engine. You can now stream an instrument window to your Saitek Flight Panel Instrument with a very simple script:

require "passerelle"
passerelle.addPage("SFIP", 1, 1, true);
function capture()
    local bitmap = passerelle.captureWindow("FS98FLOAT", "PFD", 0, 0, 100, 100);
    passerelle.setImage('SFIP', 1, 1, 0, bitmap);
while true do
To test this script in FSUIPC:
- Select a Cessna with a G1000 GPS
- Start the flight
- Open the PFD window
- Undock it (window must be in non-minimized state)
- Run the script


And voilà! Your are streaming your PFD to your FIP!


Check the installation procedure here:

This preview version can be downloaded from here:



The documentation is here:




  • 1

#489651 Simconnect Error after update to P3D v3.2.3.1679

Posted by flying-w on 14 March 2016 - 06:42 AM

The only other observation I have so far is Delete AI won't work with 3.2 without a code change.  That's a relatively simple thing to fix in the next few days.



  • 1

#489400 EFIS TFC Button

Posted by FatherDane on 07 March 2016 - 03:32 PM



I have managed to get it all sorted out.  Apparently when Roar Kristensen (the programmer for OC4BA) wrote the programme for the EFIS and MCP (from Open Cockpits) he included a way to activate both the CTR and the TFC buttons.  He set it up to press twice on the DATA button to activate TFC and twice on the WPT button to activate CTR.


It wasn't something that was published anywhere for someone like me to learn about it, but now I know, if anyone else has this problem, then this is the answer.


Thank you for taking the time and trouble with me.  It is very much appreciated

  • 1

#488785 Which Command for "Cycle Views"?

Posted by Pete Dowson on 14 February 2016 - 06:38 PM

Hi: I am reprogramming my keyboard commands with FSUIPC and this is driving me crazy...Which command should I be using for "cycle views"?...The default in P3D is the "S" key, but I cannot find the equivelent command in the FSUIPC menu...Thanks a lot...


FSUIPC's list is actually made from the internal list in P3D, contained in their "Controls.dll". FSUIPC doesn't invent them. The names can be obscure at times. In this case they are really not particularly obscure. There is a document listing them all provided in your FSUIPC Documents subfolder, in the Modules subfolder -- as pointed out in the Installation document. If you search this list for "View" you'd find, among many, others these








I think one pair is usually assigned to A/Shift A and the other to S/Shift S, but I'm not sure which is which offhand as I never use the keyboard.


In general, if you want to find precisely which FS control is being used for any action, button or switch, just go to FSUIPC's logging tab and enable Event logging. Then when you use it it will be logged with both number and name. To make it easier you can even select the "console log". Then, if you (temporarily) run P3D in Windowed mode, you can view the Log file in real time in its own Window.



  • 1

#488725 Determine if FSX has focus in Lua scripts

Posted by Pete Dowson on 12 February 2016 - 05:51 PM

FSUIPC version 4.949f is released, with Installer (because of the Lua documentation update) and includes the facilities you requested, ext.hasfocus including the handle and process name variants.



  • 1

#488669 Determine if FSX has focus in Lua scripts

Posted by Pete Dowson on 11 February 2016 - 09:17 AM

Thanks for reminding me of this request. I will be getting to it soon, probably this weekend. It's been pretty hectic here since returning from holiday, ad to make matters worse I have come down with a stinking head cold which has progressed downwards to give me a terrible cough! Surprising how much these things slow you down when you are old like me!


The first part, checking if FSX has focus, is reasonably easy -- though there can be complications, as when the focus is in a Menu. The extension to test other Windows is not so easy since the normal Focus functions in Windows only work for your current thread Window. There's also some confusion between "Foreground Window", and "Focus" which I need to clarify in my mind. Windows references mention both as if they are separate states, and both have their own functions.



  • 1

#487596 Client DLL 64bit version

Posted by Paul Henty on 08 January 2016 - 02:22 PM

I don't know if this is relevant, i also tried the new x64 client and was able to successfully compile my ACARS in 64-bit. It seems to be working flawlessly.



Great! Thanks for the feedback.



  • 1

#487581 "This has multiple actions already"

Posted by Pete Dowson on 08 January 2016 - 11:08 AM

Yes, I just thought that the numbers are not needed anymore if I use letters - and each letter is still referencing/tied to an unique GUID 


But FSUIPC uses the joystick ID numbers, 0-15, as used in the original Windows joystick API, and needs the number lines to relate the number to the GUID and Name as well as the Letters so it can understand the lettered assignments.


Anyway it actually does no harm, as you can see, FSUIPC re-constructs those from the registry next time. It might only go wrong if the registry was not complete with the IDs, and seems to happen more often now with Win8 and Win10 and Saitek drivers.


On the original problem:


I get the message "This has multiple actions already! Please edit in FSUIPC.ini" when the button, in this case A,11 is pressed/unpressed.

I found it. It is actually a very very old bug, and I'm surprised it hasn't occurred before. It was intriduced when I added the "IgnoreThese" facility (in 2008), as in your line
IgnoreThese=A.30, A.31, A.22, A.23, A.24, A.25
The code I inserted to cope with that re-uses the counter used to keep track of how many button assignments there are. This makes the Buttons Tab scan spurious entries in the table and get matches where none exist.
Without the IgnoreThese line it works fine. I'll make an interim update with this fixed today -- 4.949a. Look out for it in the Download Links subforum above later. It'll be just a replacement DLL.
Thanks for the report!

  • 1

#487407 SimPlaylist a media player FSUIPC driven

Posted by Mario DANTAS on 05 January 2016 - 05:47 PM



I've release V3 of simPlaylist


Now you can select the output soundcard


You can also start the application with "-min" in command line to start it minimized


You can control it with FSUIPC as follows;


OFFSET 736E (1byte)


Send values;


1 to start / next song

2 to stop song

3 to next song

4 to prev song



Downloadable at http://flightsimsoft.net


Some user feedback will be appretiated to improve the application.


If the improvements worths I'll buy a code singing certificate, but in the mean time you can install the application without risk.

  • 1

#487038 Screenshot Lua Script

Posted by ckovoor on 22 December 2015 - 12:33 PM

Hi Roman,

Thank you for sharing your marvellous lua script, and for introducing me to IrfanView. I have used your script in combination with Input Director macros to create (composite) panoramic screenshots of my networked FSX system comprising 7+1+7+3=18 screens. I have sent you a PM with links.



  • 1

#486767 AI Zapper - adding more parameters?

Posted by Pete Dowson on 08 December 2015 - 08:33 PM

I'll take a look at a width option.


Okay, please try this version and let me know if it works (i won't have time to test properly till the weekend):




In this the Traffic Zapper control can have a parameter as follows:



0 (default) == 15 degree deviation either way, as before

1               == 30 degree deviation either way

2               == 45 degree deviation either way

3               == 60 degree deviation either way

4               == 75 degree deviation either way



0 (default) ==  2.5 degree width either way, as before

1               ==  5.0 degree deviation either way

2               ==  7.5 degree deviation either way

3               == 10.0 degree deviation either way

4               == 12.5 degree deviation either way


Hope this meets your needs. Please test and let me know.



  • 1

#489003 IVAO Airspace File (2016-04)

Posted by VolkerHeine on 22 February 2016 - 04:52 PM

IVAO Airspace File (2016-04)


Newer IVAO Airspace data available.
You can download the file here:


Les nouvelles données IVAO espace aérien disponible.
Vous pouvez le télécharger ici:

Neue IVAO Airspace Daten erhältlich.
Den Download finden Sie hier:




  • 1

About simFlight - simflight.com - simflight.de - simflight.fr - simflight.nl - simflight.pt - simflight.es - simflight.it - simflight.jp - simrussia.com - simMarket