Jump to content
The simFlight Network Forums
svenks

Getting/Setting LED's on Saitek X52 Pro

Recommended Posts

Hi Peter

As hinted in another, older thread, I have begun looking at the possibility of using the LED's on the Saitek X52 Pro to provide some useful information. For example, if I turn off the autopilot via a joystick button, change the color of that button (or turn it off). If I can get it to work, I would even change that LED on AP turn on/off regardless of whether I used the button or not.

I have been looking at HIDdemo as well as this LINKthis LINK and not least this LINK. The last one actually deals with setting LED's on a Saitek Unit. Unfortunately, it deals with the Saitek Switch panel, not the X52. And the FSUIPC LUA COM library is not concerned with LED,s except that the last link above does use com.writefeature to set the 3 LED's on the Switch panel.

But I really have no clue on how to proceed with the X52. It has a lot of LEDs and many of them can be set to 3 colors. I tried to use com.readfeature to see if I could see something change in the output from that, if I let it run and then changed one of the LEDs via the driver/calibration software. But either I'm doing it wrong, or the X52 does not support com.readfeature, or it doesn't have "features" per se. In any case, the return value is 0, meaning that the call failed.

So I'm stuck in the water. If you, Peter or anyone can give me a clue on how to proceed, it would be much appreciated.

BRGDS

Sven Sorensen, EKCH

HidFeature.lua.txt

Share this post


Link to post
Share on other sites
3 hours ago, svenks said:

If you, Peter or anyone can give me a clue on how to proceed, it would be much appreciated.

Without access to the equipment I'd be at a bit of a loss. In any case aren't there more user-friendly ways of doing things with Saitek stuff now? Have you looked at SPAD? https://www.spadnext.com/home.html

Pete

 

 

Share this post


Link to post
Share on other sites

Hey Sven... ( you 'ol dog 😃 )

In lieu of spad next -
Does the X-52 have a calibration control panel where you can test the led's?
If so -and- the HIDFeature.lua doesn't pick up the led stuff being controlled from the control panel, maybe try Process Monitor and attach it (filter) to a Saitek .dll or something & see if that sniffs out the data needed.

Just an idea, you're much more computer savvy than I.
Hope all is well, staying healthy etc..

Roman

Share this post


Link to post
Share on other sites

Hi

Thanks for the reply, both of you. I've seen SPAD mentioned, but actually thought it was some hardware box. I'll certainly give it at go.

As for Process Monitor, I think that it would be very hard to identify those bits having to do with the LEDs. That's why I tried readfeature, but I can't be sure that the LEDs are even a feature, nor that Saitek has followed the USB Bible.

Other than that, all is well!

Brgds Sven

Share this post


Link to post
Share on other sites

Heureka!!!

There is something called x52luaout, made by erkswede. It does exactly what I want it to do, see this Youtube link

Alas! It is for X-plane only, but the name suggests to me that it should be possible to port it to P3D & FSX.

Unfortunately, I cannot seem to find anywhere where I can download it. I will try to contact erkswede.

This holds more promise than my attempts today with an USB sniffer...

BRGDS

Sven

 

  • Upvote 1

Share this post


Link to post
Share on other sites

This is only a little step for mankind, but a giant leap for me....

See the yellow LED? I made that...

But I do need to figure out how to load a C DLL from FSUIPC (or LUA or P3D) so I can call it from a LUA Script. I thought it would be a matter of just having a LUA script with a REQUIRE in it, but apparently not 😞

It is a DLL called "passerelle" and it is an interface between LUA and the SAITEK drivers. I only got it working in a debugger attached to a LUA window. But still, even a small victory is a victory,

Pete, as for SPADNext, they haven't got around to the X52 yet.

BRGDS

Sven 

Yellow_LED.jpg

Share this post


Link to post
Share on other sites
3 hours ago, svenks said:

This is only a little step for mankind, but a giant leap for me....

See the yellow LED? I made that...

But I do need to figure out how to load a C DLL from FSUIPC (or LUA or P3D) so I can call it from a LUA Script. I thought it would be a matter of just having a LUA script with a REQUIRE in it, but apparently not 😞

It is a DLL called "passerelle" and it is an interface between LUA and the SAITEK drivers.

Is it a 32-bit DLL or a 64-bit one? If you are running P3D4 or P3D5 and therefore using FSUIPC5 or FSUIPC6, you need a 64-bit DLL. Otherwise 32-bit. This is because a 64-bit process can't use a 32-bit DLL and vice versa.

If you need a 64-bit DLL but can't find one, then you could consider using WideClient and running your Lua there. You can run WideClient on the same PC as FSUIPC by setting the ClassInstance parameter non-zero, so it doesn't clash. Of course you'd need a WideFS registration.

Pete

 

Share this post


Link to post
Share on other sites

HI Pete, thanks for the answer!

Yes, I am testing on P3Dv4.5 and FSUIPC5.

But there must be more at play here. I have the DLL in both a 32 and a 64 bit version. Both produce the same

    44734 *** LUA Error: error loading module 'passerelle' from file 'D:\P3D\modules\lua\passerelle.dll':
    %1 is not a valid Win32 application.

Surely, this must must be close to the most stupid error text, when I am actuallly running a 32-bit DLL (only to be outdone by "keyboard not found - hit F1")

But it may also have to do with the LUA version. Running the 32-bit passerelle under LUA 5.1/32-bit works, 64-bit passerelle under 5.1/64-bit gives the error above. 

Running the passerelle/32 under LUA5.3/32 chrashes LUA. Running passerelle/64 under LUA5.3/64 gives the error above. NOTE: I can only build passerelle with LUA 5.1 libs and the chrash occurs in LUA 5.1 DLL.

What LUA version is FSUIPC actually running? 

BRGDS

Sven

Share this post


Link to post
Share on other sites
29 minutes ago, svenks said:

Surely, this must must be close to the most stupid error text,

Possibly. I'm not sure from whereabouts in the complex lua code that emanates. But do note that "Win32" doesn't refer to 32-bits these days. almost everything in Windows in "Win32". The main 64-bit Windows API's are still in modules with names like System32.dll and so on.

The stupid bit is the %1 which should seemingly have been replaced by the name, though the name is there anyway, "passerelle" (twice in fact).

That error message isn't in the FSUIPC Lua code.

29 minutes ago, svenks said:

64-bit passerelle under 5.1/64-bit gives the error above. 

You found a 64-bit version of 5.1? 

29 minutes ago, svenks said:

What LUA version is FSUIPC actually running? 

5.1, as mentioned in the Plug-ins document. I could have done with a 64-bit version of the Lua compiler for 5.1. Did you ever find one?

Pete

 

Share this post


Link to post
Share on other sites

Sorry, I was too hasty (<Burarum>). I don't have a 64-bit LUA 5.1. I have LOADS of other stuff, but...

/Sven

 

Share this post


Link to post
Share on other sites

Ok, I've had it!

How hard can it be to create a valid 64-bit DLL???

And I haven't got a clue as to what (if anything) I'm doing wrong.

In desperation I installed Lua for Windows (5.1.4) on my gaming PC. Copied passerelle/32bit to its clibs folder.

Tried Require("passerelle") => unable to load module from file / module not found. OK, at least it didn't say "Not a valid Win32 app"

Now, the SAME passerelle DLL on my VirtualBox testrig, also copied to LFW 5.1.4\clibs: Require("passerelle") - and it works!

Same DLL - Same LUA environment - two different outcomes.

I need a break...

/Sven

Share this post


Link to post
Share on other sites

After the break...

One word: SUCCESS!

Got the 64-bit passerelle working in FSUIPC's LUA engine, and I'm ready to begin implementing my idea for connecting offset values, buttons and LED's.

Sometimes you need to step away from the problem, to get a new view on it...

Thank you for your help, Peter

  • Upvote 1

Share this post


Link to post
Share on other sites
12 hours ago, svenks said:

Thank you for your help, Peter

But I didn't really help! :-)

What was the solution?

Pete

 

Share this post


Link to post
Share on other sites

Just by being there...😁

It 2 things: 1) The error msg was totally misleading. I did have a valid 64 bit DLL, but 2) the dependant LUA DLL had a slightly different name, lua5.1.dll instead of lua51.dll...

Thus, the passerelle DLL wouldn't load, and so I got "Not a valid win32 application".

I also began using package.load to load the DLL - though require should have worked.

Brgds Sven

Share this post


Link to post
Share on other sites
5 hours ago, svenks said:

Just by being there...😁

😉

Thanks for the explanation.

Pete

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • 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.