Jump to content
The simFlight Network Forums

Saitek Panels own driver


Recommended Posts

Hello,

I own the three Saitek Panels (Radio, Switch and Multi) and I want to develop my own driver (the Saitek one don't work with add-on aircraft and have several other problems).

I've made some reverse engineering on the panels protocol (quite easy: it's a common hid device) but I need some hints on how to interact directly with fsuipc.

What I need is to let fsuipc "see" the panels buttons and rotary switches like standard joystick buttons (is this possible ??).

Any help (links to documentation) would be really appreciated.

Thank you very much for your attention.

Massimo.

Link to comment
Share on other sites

What I need is to let fsuipc "see" the panels buttons and rotary switches like standard joystick buttons (is this possible ??).

You can interface to FSUIPC like any other FSUIPC application. You need the FSUIPC SDK. To provide facilities so you can assign functions to the buttons and switches in FSUIPC's option dialogue you can set and clear bits in the virtual buttons offsets, those starting at offset 3340. You have 288 bits at your disposal, enough to indicate the state of 288 switches or buttons (or individual multiway positions). They are seen in the FSUIPC options as joysticks 64 to 72 inclusive, 32 buttons on each.

Regards

Pete

Link to comment
Share on other sites

  • 1 month later...
I published my project a few weeks ago ( http://fstools.weebly.com ).

That's great -- I noticed from your other reply near here.

have I to sign some kind of agreement with you for using FSUIPC ? My project is freeware.

No, not for freeware. But I'd like to point folks to your site in my documentation and in my Announcements above, if that's okay?

Best Regards

Pete

Link to comment
Share on other sites

Thanks Pete for posting this. I've used your program(s) for a few years. Both 3 and 4 versions and WideFS (all reg) and they are fantastic. SPAD prompted me to send a congrats message to his website - my first post ever - and I felt I should follow up with a very hearty thanks to you for your years of great work. - I did post some fsuipc.ini files to his web (at his request) and I thought I should check with you to make sure that was alright (sorry - I should have asked first) - He's interested and has lots of requests for PMDG stuff - mine is sure not elegant but it works!!

One thing I love is the additon of LUA. My first effort - a direct substitution of your code example - was a radio display some users may fine useful. I've attached it here - If it's useful have at it. Any comments are welcome.

The fsuipc.ini I sent needs a lot of work but works really well with an EFIS/MCP panel I built for a PMDG 737. I need to play more with your mouse routines - neat addon but I'm finding some PMDG panels particularly on a split screen setup have issues.

Anyway thanks again for great stuff.!!!

edfair

Link to comment
Share on other sites

Sorry hit the submit button without the Lua attachment. (I guess it won't take a .txt or .lua file so here:

-- "Display radios" example LUA plug-in, by Ed Fairchild, December 2009

-- Loop forever: to stop this you'll have to use the LuaKill control on it.

while 1 do

-- Converts a decimal value in bcdnum to a string of the form "19.90"

function nav2mhz(val)

c1=tostring(val)

c2=string.sub(string.format("%x",c1),1,2)

c3=string.sub(string.format("%x",c1),3,4)

c4=string.sub(c2,1,1)

c5="1"..c2..c3

if c4=="8" or c4=="9"then c5="10"..c2..c3 end

c6=string.sub(c5,1,3).."."..string.sub(c5,4,5)

return c6

end

-- Get all of the data we want to display

com1 = ipc.readUW(0x034E)

com2 = ipc.readUW(0x3118)

com1sb = ipc.readUW(0x311A)

com2sb = ipc.readUW(0x311C)

nav1 = ipc.readUW(0x0350)

nav2 = ipc.readUW(0x0352)

nav1sb = ipc.readUW(0x311E)

nav2sb = ipc.readUW(0x3120)

adf1 = ipc.readUW(0x034C)

adf2 = ipc.readUW(0x02D4)

xpd = ipc.readUW(0x0354)

adf1a =tostring(adf1)

adf1b =string.sub(string.format("%x",adf1a),1,4)

adf2a =tostring(adf2)

adf2b =string.sub(string.format("%x",adf2a),1,4)

xpda =tostring(xpd)

xpdb =string.sub(string.format("%x",xpda),1,4)

stat = ipc.readUB(0x66c0)

co1 = nav2mhz(com1)

co2 = nav2mhz(com2)

co1s = nav2mhz(com1sb)

co2s = nav2mhz(com2sb)

n1 = nav2mhz(nav1)

n2 = nav2mhz(nav2)

n1s = nav2mhz(nav1sb)

n2s = nav2mhz(nav2sb)

-- test for stat

if stat == 0 then reply="Throttle"

elseif stat == 1 then reply="COM"

elseif stat == 2 then reply="Panels"

elseif stat == 3 then reply="Lights"

elseif stat == 4 then reply="NAV"

elseif stat == 5 then reply="XPNDR"

elseif stat == 6 then reply="ADF"

end

-- display it all in an FS window

ipc.display("\------------------------------"..

"\n** Quad keys = "..reply.." **"..

"\n------------------------------"..

"\n COM1 = "..co1.." <- "..co1s..

"\n COM2 = "..co2.." <- "..co2s..

"\n------------------------------"..

"\n NAV1 = "..n1.." <- "..n1s..

"\n NAV2 = "..n2.." <- "..n2s..

"\n------------------------------"..

"\n ADF1 = "..adf1b..

"\n ADF2 = "..adf2b..

"\n------------------------------"..

"\n Transponder = "..xpdb..

"\n")

-- Sleep for 50 mSecs so the update gets done roughly 20 times per second

ipc.sleep(50)

--

end

Link to comment
Share on other sites

One thing I love is the additon of LUA. My first effort - a direct substitution of your code example - was a radio display some users may fine useful. I've attached it here - If it's useful have at it. Any comments are welcome.

I see it in the subsequent post. Thanks!

I need to play more with your mouse routines - neat addon but I'm finding some PMDG panels particularly on a split screen setup have issues.

That may be only related to mouse detection. If you can first program the mouse macros without moving the panels then it doesn't matter if you move them or even remove them afterwards, because the mouse and the position is then not relevant. FSUIPC records and uses the internal code positions directly, it doesn't care about the displays thereafter.

Regards

Pete

Link to comment
Share on other sites

Sorry hit the submit button without the Lua attachment. (I guess it won't take a .txt or .lua file so here

Easiest is to paste into your message, as you have done, but then use the "code" button to enclose it for selection and scrolling, thus:

(See that it also preserves indents, which I've put back in for you).

-- "Display radios" example LUA plug-in, by Ed Fairchild, December 2009

-- Loop forever: to stop this you'll have to use the LuaKill control on it.

while 1 do

-- Converts a decimal value in bcdnum to a string of the form "19.90"

function nav2mhz(val)
	c1=tostring(val)
	c2=string.sub(string.format("%x",c1),1,2)
	c3=string.sub(string.format("%x",c1),3,4)
	c4=string.sub(c2,1,1)
	c5="1"..c2..c3
		if c4=="8" or c4=="9"then c5="10"..c2..c3 end
	c6=string.sub(c5,1,3).."."..string.sub(c5,4,5)
		return c6
end

-- Get all of the data we want to display

com1 =   ipc.readUW(0x034E)
com2 =   ipc.readUW(0x3118)
com1sb = ipc.readUW(0x311A)
com2sb = ipc.readUW(0x311C)
nav1 =   ipc.readUW(0x0350)
nav2 =   ipc.readUW(0x0352)
nav1sb = ipc.readUW(0x311E)
nav2sb = ipc.readUW(0x3120)
adf1 =   ipc.readUW(0x034C)
adf2 =   ipc.readUW(0x02D4)
xpd =    ipc.readUW(0x0354)

adf1a =tostring(adf1)
adf1b =string.sub(string.format("%x",adf1a),1,4)
adf2a =tostring(adf2)
adf2b =string.sub(string.format("%x",adf2a),1,4)

xpda  =tostring(xpd)
xpdb  =string.sub(string.format("%x",xpda),1,4)

stat =   ipc.readUB(0x66c0)

co1 =  nav2mhz(com1)
co2 =  nav2mhz(com2)
co1s = nav2mhz(com1sb)
co2s = nav2mhz(com2sb)
n1 =   nav2mhz(nav1)
n2 =   nav2mhz(nav2)
n1s =  nav2mhz(nav1sb)
n2s =  nav2mhz(nav2sb)

-- test for stat

if stat == 0 then reply="Throttle"
 elseif stat == 1 then reply="COM"
 elseif stat == 2 then reply="Panels"
 elseif stat == 3 then reply="Lights"
 elseif stat == 4 then reply="NAV"
 elseif stat == 5 then reply="XPNDR"
 elseif stat == 6 then reply="ADF"
end

-- display it all in an FS window

ipc.display("\------------------------------"..
"\n** Quad keys = "..reply.." **"..
"\n------------------------------"..
"\n COM1 = "..co1.." &lt;- "..co1s..
"\n COM2 = "..co2.." &lt;- "..co2s..
"\n------------------------------"..
"\n NAV1 = "..n1.." &lt;- "..n1s..
"\n NAV2 = "..n2.." &lt;- "..n2s..
"\n------------------------------"..
"\n ADF1 = "..adf1b..
"\n ADF2 = "..adf2b..
"\n------------------------------"..
"\n Transponder = "..xpdb..
"\n")

-- Sleep for 50 mSecs so the update gets done roughly 20 times per second

ipc.sleep(50)

--

end

Regards

Pete

Link to comment
Share on other sites

I noticed after I posted the lua routine that I had left in a small segment looking at a variable called reply. This was set in my fsuipc.ini to allow me to switch between a number of key assignment sets on my throttle quadrant. Prior to luas display function I had difficulty displaying what keyset was active. That function in itself was a great plus and I elaborated on it in later lua sub to allow active display of all the key assignments. The Lua addon makes it easy to display lots of little prompt screens - it's great for semi-programmers like myself. Thanks again.

I don't see a lot of ini files posted on your site. Any thoughts yea or nay? I'm always glad to share code ideas. (clumsy though some of mine may be)

edfair :)

Link to comment
Share on other sites

I don't see a lot of ini files posted on your site. Any thoughts yea or nay? I'm always glad to share code ideas. (clumsy though some of mine may be)

"INI files". No, they are user-system dependent. You presumably meant Lua files and Macros. When they are generally useful I put them into the batch of examples which go out with FSUIPC. Some rather more specialised ones are in Stickies at the top of the Forum. mostly related to specific aircraft. I have noticed some Lua solutions appearing on other Forums too.

The problem for me is that is is a full time job doing what I do already without taking on a sort of librarian job. I'm not terribly sure how I would handle it if there were lots of contributions. I'd feel I had to check them all out myself before making it look like they had a seal of approval, and that by itself is potentially a lot of work.

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.