Saitek X52 Pro MFD plugin - Version 1.1

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Saitek X52 Pro MFD plugin - Version 1.1

Post by Exi » Wed, 29. Jun 11, 00:31

Saitek X52 Pro MFD plugin

Version 1.1 update
Changes:
- Added new MFD page: Compatible missiles - useful for people like me who sometimes have no idea which missiles are compatible with the current ship while looking at the missile stock in a station
- Changed money/min calculation formula, should be more accurate now
- Fixed Cargo and Equipped lists, they were not updating correctly
- (D) LED remained flashing red after you had low hull/shields and your shields recovered, fixed
- Fixed some bugs which could cause lockups in the MFD updater thread

Script SPK: http://www.mediafire.com/?4nyqv95jit4nsm3
Script zip: http://www.mediafire.com/?280yxn6to9eu02i
Application: http://www.mediafire.com/?dt20bwznd24sdpr

Use the SPK version with Cyrows plugin manager http://cycrow.thexuniverse.us/XPluginMa ... taller.exe, it works with AP!

Known problems:
- Incoming missiles damage warning is not working correctly, will be fixed in the next version

If you are updating from the V1.0 version simply overwrite the files with the new ones.
------------------------------------------------------------------------------------------------------------------

Here it is, the first release of my Saitek X52 plugin for X3:TC :)

There are 2 parts, an X3 AL script which exports game data and a windows application which interprets this data and displays the pages on the MFD and handles the LEDs.

MFD Pages:

Equipped missile page:
Type
Damage
Speed
Estimated travel time to target if fired
Stock in cargo hold
Flags (heat seaking, swarm, etc)

Player page:
Ship name / class
Hull numeric / %
Shield numeric / %
Laser energy numeric / %
Current money
Money change / minute (based on last hour played, SETA time is correctly handled)

Target page:
Name / class
Hull numeric / %
Shield numeric / % - normally these should need freight scanner but most of us know anyway that X ship has XY MJ/GJ shields normally, so I don't consider this a cheat
Enemy/Neutral/Friend

Incoming missiles page:
Closest missile:
Type
Damage
Speed
Estimated time until impact
- All incoming missiles:
Number incoming
Total damage

Cargo page:
List of goods in cargo hold

Equipped page:
List of equipped stuff on player ship

Left scroll wheel changes pages, right wheel scrolls text up/down.
Pressing the right wheel jumps to the top of the current page.


LED feedbacks:

Shield feedback:
T1/2 - 3/4 - 5/6 changes colors:

GGG 100 - 85
GGY 84 - 71
GYY 70 - 57
YYY 56 - 44
YYR 43 - 30
YRR 29 - 16
RRR 15 - 0


Hull feedback:
T1/2 - 3/4 - 5/6 flashing

No flashing 100
Very slow 99 - 80
Slow 79 - 60
Medium 59 - 40
Fast 39 - 20
Very fast 19 - 0

If you have shields<15% and hull<20% ALL LEDs will flash red.
If the shields power up only the T LEDs continue to flash until hull is repaired, all other LEDs resume normal operation.


(A) LED: Selected missiles str compared to target:
- off : no missile equipped
- green : will cause only shield damage
- yellow : will destroy shield and cause some hull damage
- red : will blow target to tiny little pieces

Fire LED:
- off: no missile equipped
- flashing speed shows targets range compared to equipped missiles range
- slow flash: target too far
- fast flash: target getting near enough
- on : target in range

POV2 LED: target status
- off : no target
- green : friendly
- yellow : neutral
- red : enemy
- red and flashing : enemy / stronger ship than yours (based on class/shield/hull)

(I) LED: closest incoming missile damage if hit:
- off : no incoming missile
- green flashing - only shield damage
- yellow flashing - hull damage expected
- red - you will not survive

(E) LED: all incoming missiles damage if all hit:
- off: no more incoming missile
- green flashing - only shield damage
- yellow flashing - hull damage expected
- red - you will not survive

(B) LED: Laser energy
- off : no weapons installed
- green: 100 - 75%
- yellow: 74 - 50 %
- red: 49 - 20 %
- red and flashing: <20%

(D) LED: ??? ideas welcome

Throttle LEDs: ship docked or 0 speed: off
ship moving : on
ship moving backward : flashing


About the app:
The 32bit version of the directoutput.dll is REQUIRED to run the application. At start, it will try to detect the correct path of the dll, looking for it in
- C:\Program Files (x86)\Saitek\DirectOutput\DirectOutput.dll or
- C:\Program Files\Saitek\DirectOutput\DirectOutput.dll
These are the default locations on 64bit and 32bit systems. If your saitek drivers are not installed to the default location or if your system drive is not C: it will fail to automatically locate the dll, you will need to tell it manually where it resides by pressing the Browse button. It can be anywhere, can have any name as long as you select the correct file. The one I have on my system is version 6.2.2.4, size 114688 bytes.

The same applies to the X3 log folder, it will try to look for it in [your documents folder]\Egosoft\X3TC. If you have your X3 logfiles (log*.txt) somewhere else hit the Browse button and select the correct folder.

After selecting the correct folders hit 'Save paths' and you won't have to do it again. (Saved to settings.ini)

If everything is OK, you should see a 'X52 Pro found and initialized!' message in the log window. If something goes wrong, it will display the error message also in the log window.

There is a 'ReInit' button. Hitting this will:
- Deinitialize the controller
- Unload the DLL
- Restart the Saitek directoutput service
- Load the DLL
- Initialize the controller

After a cycle, again, you should see the 'X52 Pro found and initialized!' message. Important: The ONLY supported device is the Saitek X52 Pro.

During testing, the DirectOutput library proved to be quite buggy. I tried to mitigate this by coding the app as fault-proof as possible, but still, problems, lockups can happen (but should be rare). If the MFD becomes unresponsive or the LEDs dont react correctly try to alt-tab out and hit the ReInit button. That should fix it and you can resume playing.

Known problems/limitations:
- If you change the current page using the left scroll the LEDs revert to the default state for a short time. This is because LED states are linked to the active page and a page change wipes the data, so they will all lit up until the next update cycle (which is every 50ms).
- Sometimes at a page chage the device does not send back data to the application (using the callback routine) so the app loses track of which is the currently active page. The sign of this is that all LEDs revert to the default state and dont do what they should. Changing the page again usually fixes it and normal operation is resumed. Again, this is a bug in the directoutput library.
- Changing LED brightness is not implemented currently. There is a function in the Saitek control panel for this, but its not documented/not included in the dll. Support for this - and better looking led effects - is possible in the future.

To develop my own dll wrapper I used documentation and code parts from other people, so they deserve credit for they work: Frederic Valery (Blackswift) and ellF (on saitekforum.com)
Some of the LED feedback ideas were taken from RotCurtSed's X3 Reunion plugin.

The scripts and the app is provided as-is: by using them you accept that I can't take responsibility if it sets your computer on fire, formats your harddrive or makes your girlfriend leave you. You were warned.

If you want to develop your own plugin contact me and I can send you source code. The app and the dll wrapper was written in delphi, compiled with RAD Studio 2010.

[ external image ] [ external image ]

Cheers,

Exi
Last edited by Exi on Sun, 5. Aug 12, 13:23, edited 5 times in total.

ctcc41
Posts: 67
Joined: Sun, 19. Dec 04, 22:40
x3tc

Post by ctcc41 » Wed, 29. Jun 11, 01:52

I realy dont know what the limits of what you can and can't do are, and you have listed all the simple stuff already, any way, so I just want to encorage you. Make this and I for one will download it.
To error is human, to totaly screw things up takes a computer.

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Wed, 29. Jun 11, 07:11

If you have a x52 you know the physical limits: 3 lines of text on each page (well, 3x16 chars, if you put in more it will scroll automatically), all the LED's can have 4 states: off, green, red or amber, except the missile fire and the throttle illumination, those 2 can only either on or off, no color control. It's possible to assign functions to the MFD's buttons like change page (Player data, Missile data, Target data, etc) or display a different value on the current page. I already have a working, multi-threaded LED control "engine", I only need to tell it "set LED X to red and blink it fast" and it will do until I command otherwise (5 blinking speeds possible), all LEDs are independent from eachother.

The Saitek control panel can control LED brightness too, I couldn't figure out that one, it's not documented. There is a 3rd party app written for linux that can do it, maybe I'll contact the author and ask him about details.

My only concern is the update frequency/timeout because there is no direct connection to the game engine, all data is aquired by using a script in X3 which will export data to a log file. This still needs testing, I dont know which is the lowest possible update frequency, but the timeout should be fairly low, I'm thinking about 2-500ms, that will feel almost realtime.

Other limitation from X3's side shouldn't occur: whatever it can export to a txt (log) file I can read with the plugin and display it or react to it somehow.

Exi

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Wed, 29. Jun 11, 08:12

The Saitek control panel can control LED brightness too, I couldn't figure out that one, it's not documented. There is a 3rd party app written for linux that can do it, maybe I'll contact the author and ask him about details.
http://en.wikipedia.org/wiki/Pulse-width_modulation

My only concern is the update frequency/timeout because there is no direct connection to the game engine, all data is aquired by using a script in X3 which will export data to a log file. This still needs testing, I dont know which is the lowest possible update frequency, but the timeout should be fairly low, I'm thinking about 2-500ms, that will feel almost realtime.
2 MS way to fast, if your wiring to a log file every 2 MS, your taking up a ridiculous amount of cpu time - witch will cause the script engine to stall - especially in Seta
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Wed, 29. Jun 11, 08:14

I mean 200-500 ms ;)

hydra_one
Posts: 105
Joined: Wed, 14. Feb 07, 07:42
x3tc

Post by hydra_one » Sun, 3. Jul 11, 19:56

Oh now I can hardly wait lol!!!

kristiants1
Posts: 3
Joined: Sat, 16. Oct 10, 17:24

Post by kristiants1 » Fri, 8. Jul 11, 15:44

Does this also work with X3: Reunion? :? I hope it does! :wink: Also, you were talking about RotCurtSed's X3 Reunion plugin, what does that do and where can it be found? Thanks! (An :idea: IDEA :idea: for the [D] button is maybe total weapon energy?)

irR4tiOn4L
Posts: 663
Joined: Wed, 19. Oct 05, 14:07
x3tc

Post by irR4tiOn4L » Sat, 9. Jul 11, 07:33

Do you know if this would work with the older X52 (non pro)? It has the same MFD

kristiants1
Posts: 3
Joined: Sat, 16. Oct 10, 17:24

Post by kristiants1 » Sat, 9. Jul 11, 07:50

I would imagine it wouldn't, because it can't change the button color. Can you turn the button lights on and off? I'm just wondering. Also, I'm not sure but I THINK they have different plugins, correct me if I'm wrong.

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Sun, 10. Jul 11, 19:53

X3:Reunion is not supported in this release. It's possible that I'll do an update later but don't take this as a promise. There were working plugins for X3:R, heres RotCurtSed's original topic: http://www.saitekforum.com/showthread.php?t=13938
My aim was to create one for TC as I couldn't find any that is at least partially working, everyone who opened a topic regarding a new plugin gave up and never finished the work.

X52 non-pro is not supported and never will be. Sorry :( The 2 just look the same but the internals are completely different. As far as I know the non-pro doesn't have tri-state leds and the MFD can be used only with those programs (mainly MS Flight Sim series) that have built-in support. The SDK available from Saitek supports only the Pro model, thats what I worked with. So unless Saitek releases a SDK for the non-pro (they won't) its next to impossible to create software for it.

Cheers,

Exi

kristiants1
Posts: 3
Joined: Sat, 16. Oct 10, 17:24

Post by kristiants1 » Mon, 11. Jul 11, 07:57

Ok, I won't take it as a promise, but I'll keep an eye out for the update. Thanks for the link, and thanks for the help! :)

Giossepi
Posts: 2
Joined: Thu, 28. Jul 11, 06:56

help

Post by Giossepi » Thu, 28. Jul 11, 06:58

i donwloaded all 3 files and installed but no .logs are being made, and i have no clue what to do with the .spk so if someone can tell me how to install this that would be great, also i own the game on steam if that makes a difference

Giossepi
Posts: 2
Joined: Thu, 28. Jul 11, 06:56

Post by Giossepi » Thu, 28. Jul 11, 18:45

anyone? some help would be nice as i would love to use this with my x52

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Tue, 2. Aug 11, 08:49

You need Cycrow's plugin manager to be able to install SPK files: http://cycrow.thexuniverse.us/

The SPK contains the scripts that are needed to export in-game data from X3. Just download the plugin manager, install the SPK and done.

Giggzee
Posts: 2
Joined: Thu, 18. Aug 11, 13:34

Post by Giggzee » Thu, 18. Aug 11, 13:38

Exi
good. i thought the process would much more complicated))
Last edited by Giggzee on Sat, 27. Aug 11, 21:12, edited 1 time in total.
How To Use Your Spy Earpiece For Maximum Benefit
Useful Features Of Spy Earpiece

User avatar
Drewgamer
Posts: 536
Joined: Fri, 27. Aug 10, 08:39
x4

Post by Drewgamer » Fri, 26. Aug 11, 16:19

Just wanted to say thanks for this awesome app/script combo. I recently got an x52 Pro and being able to utilize its full functionality will be great.
Check out my mod Crystal Rarities

Kinnison
Posts: 159
Joined: Wed, 11. Feb 04, 00:18
x3ap

Post by Kinnison » Sat, 27. Aug 11, 23:05

Useful app, thanks a lot. It works fine on my kit except for being unable to change the MFD page - the left wheel doesn't do anything and I'm stuck with the player ship readout. Right wheel scrolling is OK.

I've tried reinitialising a few times, no luck.

W7 Pro 64 on i7.

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Thu, 1. Sep 11, 20:38

I`ll add debug option in the next version so we can see whats going wrong there. I never experienced unresponsive scroll wheel while testing, sounds strange...

Kinnison
Posts: 159
Joined: Wed, 11. Feb 04, 00:18
x3ap

Post by Kinnison » Thu, 1. Sep 11, 22:37

Thanks, I'd be interested to find out too.

Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Post by Exi » Sun, 4. Sep 11, 15:30

Kinnison - and possibly others having problems - try to download and run this build: X52 debug build
Just copy the file to the same folder where the original one resides.

Enable debug mode with the checkbox and use the buttons and everything like you normally would. A logfile will be created at logs\debug.log.
Send me that file in email and I'll compare with mine to see whats wrong.
Please provide your Saitek driver version as well.

It's possible that you are using a different driver/DLL and that changed the signals /data format the controller is using, in that case I'll need to add support for that in the app.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”