The Official Saitek Forum  

Go Back   The Official Saitek Forum > General > X52 Pro MFD Plug-in/SDK discussion
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 16th June 2007, 12:30
gunichou gunichou is offline
Registered User
 
Join Date: Jun 2007
Posts: 4
X52 pro+ MFD+ IL2 1946

Hey all.I just receive my X52 pro today and i love it!
I just want to know if someone can create a mod for IL2 1946? I like to view on my MFD my altitude, my speed and my cap.Is it possible to create one ?


PS: Sorry for my bad english
Reply With Quote
  #2  
Old 20th June 2007, 20:29
Spksh's Avatar
Spksh Spksh is offline
Registered User
 
Join Date: Apr 2003
Location: The ass-end of space
Posts: 511
You need to be able to program in C++ (or VB6 or C# if you use the user-created SDKs) to make applications for the X52 Pro. It takes many, many hours to write an application to do what you want, assuming the game even supports it.

Do you know if IL2 has an API to pull flight data from?
Reply With Quote
  #3  
Old 27th June 2007, 22:36
Fugazi Fugazi is offline
Registered User
 
Join Date: Dec 2003
Location: USA
Posts: 92
Long time ago, I wrote an application for IL2 in order to have a feedback on the screen for several settings notably Trim and Stick axes values. The problem was that this application had to hack into OpenGL, and because I never wrote it to be compatible with DirectX, it was not able to display the overlay if the game was using DirectX instead of OpenGL. For OpenGL though it was fine, and having the feedback of my Trims or Stick in quasi realtime on the screen helped me to troubleshoot joystick and trim issues.

For the last day I am playing around with the SDK though, and like Spksh, I wrapped everything into a C# library (see the code below). Of course I still have some work to do, but I can display several pages now from a client in C#, responding to the softbuttons. I will have to dig through some code written in .NET 1.1, upgrade it to .NET 2.0 and I will be able to display those informations on the pages of the X52. I will let you know how its works (I do not plan to spend more than few minutes a day to do it in the near future).

C# Wrapper
Code:
// GUID Structure [StructLayout(LayoutKind.Sequential)] public struct GUID { public UInt32 a; public UInt16 b; public UInt16 c; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public Byte[] d; public GUID(UInt32 a, UInt16 b, UInt16 c, Byte[] d) { this.a = a; this.b = b; this.c = c; this.d = d; } } // Wrapper public class DirectOutput { #region Delegates //void __stdcall DirectOutput_Device_Callback(void* hDevice, bool bAdded, void* pvContext); public delegate void DeviceChangeCallback(IntPtr device, Boolean added, IntPtr context); //void __stdcall DirectOutput_SoftButton_Callback(void* hDevice, DWORD dwButtons, void* pvContext); public delegate void SoftButtonChangeCallback(IntPtr device, UInt32 buttons, IntPtr context); //void __stdcall DirectOutput_Page_Callback(void* hDevice, DWORD dwPage, bool bActivated, void* pvContext); public delegate void PageChangeCallback(IntPtr device, UInt32 page, Boolean activated, IntPtr context); #endregion Delegates #region Fields private const String Reference = "DirectOutput.dll"; // HResult values public const UInt32 S_OK = 0x00000000; public const UInt32 E_ABORT = 0x80004004; public const UInt32 E_ACCESSDENIED = 0x80070005; public const UInt32 E_FAIL = 0x80004005; public const UInt32 E_HANDLE = 0x80070006; public const UInt32 E_INVALIDARG = 0x80070057; public const UInt32 E_NOINTERFACE = 0x80004002; public const UInt32 E_NOTIMPL = 0x80004001; public const UInt32 E_OUTOFMEMORY = 0x8007000E; public const UInt32 E_POINTER = 0x80004003; public const UInt32 E_UNEXPECTED = 0x8000FFFF; // Device Type GUID public static GUID DEVICETYPE_X52PRO = new GUID((UInt32)0x29DAD506, (UInt16)0xF93B, (UInt16) 0x4F20, new Byte[8] { 0x85, 0xFA, 0x1E, 0x02, 0xC0, 0x4F, 0xAC, 0x17 }); // Soft Buttons public const UInt32 SOFTBUTTON_SELECT = 0x00000001; public const UInt32 SOFTBUTTON_UP = 0x00000002; public const UInt32 SOFTBUTTON_DOWN = 0x00000004; // Unused soft buttons public const UInt32 SOFTBUTTON_LEFT = 0x00000008; public const UInt32 SOFTBUTTON_RIGHT = 0x00000010; public const UInt32 SOFTBUTTON_BACK = 0x00000020; public const UInt32 SOFTBUTTON_INCREMENT = 0x00000040; public const UInt32 SOFTBUTTON_DECREMENT = 0x00000080; #endregion Fields #region Public Interface //HRESULT DirectOutput_Initialize(const wchar_t* wszAppName); [DllImport(Reference, EntryPoint = "DirectOutput_Initialize")] public static extern UInt32 Initialize([In, MarshalAs(UnmanagedType.LPWStr)] String appName); //HRESULT DirectOutput_Deinitialize(); [DllImport(Reference, EntryPoint = "DirectOutput_Deinitialize")] public static extern UInt32 Deinitialize(); //HRESULT DirectOutput_RegisterDeviceChangeCallback(Pfn_DirectOutput_Device_Callback pfnCallback, void* pvParam); [DllImport(Reference, EntryPoint = "DirectOutput_RegisterDeviceChangeCallback")] public static extern UInt32 RegisterDeviceChangeCallback(DeviceChangeCallback function, IntPtr context); //HRESULT DirectOutput_Enumerate(); [DllImport(Reference, EntryPoint = "DirectOutput_Enumerate")] public static extern UInt32 Enumerate(); //HRESULT DirectOutput_GetDeviceType(void* hDevice, LPGUID pGuidType); [DllImport(Reference, EntryPoint = "DirectOutput_GetDeviceType")] public static extern UInt32 GetDeviceType(IntPtr device, ref GUID guid); //HRESULT DirectOutput_GetDeviceInstance(void* hDevice, LPGUID pGdInstance); [DllImport(Reference, EntryPoint = "DirectOutput_GetDeviceInstance")] public static extern UInt32 GetDeviceInstance(IntPtr device, ref GUID guid); //HRESULT DirectOutput_RegisterSoftButtonChangeCallback(void* hDevice, Pfn_DirectOutput_SoftButton_Callback pfnCallback, void* pvContext); [DllImport(Reference, EntryPoint = "DirectOutput_RegisterSoftButtonChangeCallback")] public static extern UInt32 RegisterSoftButtonChangeCallback(IntPtr device, SoftButtonChangeCallback function, IntPtr context); //HRESULT DirectOutput_RegisterPageChangeCallback(void* hDevice, Pfn_DirectOutput_Page_Callback pfnCallback, void* pvContext); [DllImport(Reference, EntryPoint = "DirectOutput_RegisterPageChangeCallback")] public static extern UInt32 RegisterPageChangeCallback(IntPtr device, PageChangeCallback function, IntPtr context); //HRESULT DirectOutput_AddPage(void* hDevice, DWORD dwPage, const wchar_t* wszName, BOOL bSetActive); [DllImport(Reference, EntryPoint = "DirectOutput_AddPage")] public static extern UInt32 AddPage(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 page, [MarshalAs(UnmanagedType.LPWStr)] String name, Boolean active); //HRESULT DirectOutput_RemovePage(void* hDevice, DWORD dwPage); [DllImport(Reference, EntryPoint = "DirectOutput_RemovePage")] public static extern UInt32 RemovePage(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 page); //HRESULT DirectOutput_SetLed(void* hDevice, DWORD dwPage, DWORD dwLed, DWORD dwValue); [DllImport(Reference, EntryPoint = "DirectOutput_SetLed")] public static extern UInt32 SetLed(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 page, [MarshalAs(UnmanagedType.U4)] UInt32 led, [MarshalAs(UnmanagedType.U4)] UInt32 value); //HRESULT DirectOutput_SetString(void* hDevice, DWORD dwPage, DWORD dwString, const wchar_t* wszValue); [DllImport(Reference, EntryPoint = "DirectOutput_SetString")] public static extern UInt32 SetString(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 page, [MarshalAs(UnmanagedType.U4)] UInt32 index, [MarshalAs(UnmanagedType.U4)] UInt32 len, [MarshalAs(UnmanagedType.LPWStr)] String value); //HRESULT DirectOutput_SetImage(void* hDevice, DWORD dwPage, DWORD dwImage, const LPBYTE pbValue, DWORD cbValue); [DllImport(Reference, EntryPoint = "DirectOutput_SetImage")] public static extern UInt32 SetImage(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 page, [MarshalAs(UnmanagedType.U4)] UInt32 index, [MarshalAs(UnmanagedType.LPArray)] Byte[] value, [MarshalAs(UnmanagedType.U4)] UInt32 len); //HRESULT DirectOutput_SetProfile(IN void* hDevice, IN DWORD cchFilename, IN const wchar_t* wszFilename) [DllImport(Reference, EntryPoint = "DirectOutpyt_SetProfile")] public static extern UInt32 SetProfile(IntPtr device, [MarshalAs(UnmanagedType.U4)] UInt32 len, [MarshalAs(UnmanagedType.LPWStr)] String fileName); #endregion Public Interface }
As you can see Spksh, this class is a little bit different than the one you wrote, and all the functions of the SDK have been ported too. I did not test all of those funtions however, the syntax may be out of synchronisation with the Saitek library.
Reply With Quote
  #4  
Old 27th June 2007, 22:45
Spksh's Avatar
Spksh Spksh is offline
Registered User
 
Join Date: Apr 2003
Location: The ass-end of space
Posts: 511
Thanks for that, Fugazi. And yeah, yours is different; I'd guess that's because you know what you're doing, and I don't (mine was my first foray into anything beyond jscript)

How are you grabbing trim settings from IL2?
Reply With Quote
  #5  
Old 28th June 2007, 00:57
Fugazi Fugazi is offline
Registered User
 
Join Date: Dec 2003
Location: USA
Posts: 92
Quote:
Originally Posted by Spksh View Post
Thanks for that, Fugazi. And yeah, yours is different; I'd guess that's because you know what you're doing, and I don't (mine was my first foray into anything beyond jscript)

How are you grabbing trim settings from IL2?
There is an API for 1946 that alllows user to pull some data from the game. I simply get the Trim settings by asking the game what are the current values. This work well for axis, and the game tells me that the axis is at that value (which I translate into percentage, negative or positive depending on the value of the trim). So I simply display a value between -100 and -100. You can pull the position of any axes from the game whether you are playing offline or online, however, most of the other value (like speed, vertical speed, pressure, temperature and so forth) are not accessible online. Look for a file call DeviceLink.txt in your IL2 folder, it describes how the data can be pulled from the game.

PS: And yes my class is a little bit different, and also I do think a little bit better than your implementation. You can grab it and use it if you want, if it may be of any help.

Last edited by Fugazi : 28th June 2007 at 01:00.
Reply With Quote
  #6  
Old 28th June 2007, 01:11
Spksh's Avatar
Spksh Spksh is offline
Registered User
 
Join Date: Apr 2003
Location: The ass-end of space
Posts: 511
Quote:
Originally Posted by Fugazi View Post
PS: And yes my class is a little bit different, and also I do think a little bit better than your implementation. You can grab it and use it if you want, if it may be of any help.
Thanks, I will.
Reply With Quote
  #7  
Old 7th December 2007, 15:22
m4sherman m4sherman is offline
Registered User
 
Join Date: Nov 2007
Posts: 7
How do you do this(pretend you are talking to an idiot )
Reply With Quote
  #8  
Old 13th December 2007, 04:22
III/JG11_Reaper III/JG11_Reaper is offline
Registered User
 
Join Date: Aug 2007
Posts: 34
Fugazi,,,,That is awsome man,,great stuff....
Reply With Quote
  #9  
Old 6th January 2008, 20:51
Deliverator Deliverator is offline
Registered User
 
Join Date: Jan 2008
Posts: 4
I'm looking forward to test it. Really outstanding work guy !!!
Reply With Quote
  #10  
Old 31st January 2008, 22:30
Frode45 Frode45 is offline
Registered User
 
Join Date: Jan 2008
Posts: 1
Fugazi

Thanks for your nice work.

I play mostly LOCK ON, how do you send to MDF in that game
is it posible to get a copy of your verson, and were can i get it

do you have a copy of IL2 verson to

best regards
Reply With Quote
  #11  
Old 2nd February 2008, 14:17
czuk czuk is offline
Registered User
 
Join Date: Jan 2008
Posts: 1
I wonder if there is anything like a "Howto" Tutorial available in order to get this stuff working.

I use the IL2 Extension for X52 and added the devicelink part into the conf.ini however nothing is displayed on my X52 Pro MFD. The MFD actually stopped showing the active profile on the MFD

I use the latest SST and Driver Software available on Saitek's Website. Direct Output is also running (at least the Taskmanager tells that).
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 20:02.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) Saitek 2001