Jump to content
The simFlight Network Forums

Helps required on Fs9 Plugin(Module) development


Recommended Posts

Hi Pete,

Seems I am asking a question that have almost nothing to do with FSUIPC, but still, thank you for your help for my previous program.

Recently I want to make a program( module dll) that could "run" under FS9,like FSUIPC and other modlules. xD

but I know nothing about how to make a fs9 pulgin.. - - so sad...

I did find the FS9 SDK on microsoft's website but i don't know which one could helps me.

Could you tell me where i could find those documents on making a FS9 pulgin?

Thank you!

Regards

Johnson

Link to comment
Share on other sites

Recently I want to make a program( module dll) that could "run" under FS9,like FSUIPC and other modlules. xD

but I know nothing about how to make a fs9 pulgin.. - - so sad...

Pretty much every one written was done by hacking into FS with debugging and disassembling tools in order to find out how to hook into it. Do you have that sort of experience and tools available?

I did find the FS9 SDK on microsoft's website but i don't know which one could helps me.

The nearest thing in the SDK would be the C gauge writing stuff (not XML). C Gauges (.GAU files) are just DLLs like FSUIPC and others, but loaded via the PANEL.CFG instead of automatically. If they were renamed .DLL and placed in the Modules folder they'd load like other DLLs (though not necessarily work).

Could you tell me where i could find those documents on making a FS9 pulgin?

None by Microsoft. There was a sort of template DLL which you could build upon published by someone, but that was back in FS98 or FS2000 days. I don't know if it is still available. The DLL loading and linking methods used in FS9 date way back to at least FS95. They only got changed in FSX.

Regards

Pete

Link to comment
Share on other sites

So sad to hear that...

I got no exp on that area and Im just a beginner...

Btw, I uesd "dependency walker" to analyse those module dlls, found that all those dlls got 2 common exported functions " Importable" &"Linkage"

Let me make a silly guess, are those 2 functions working as the "entry point"?

Anyway, thank you very much on this.

regards

johnson

Link to comment
Share on other sites

Btw, I uesd "dependency walker" to analyse those module dlls, found that all those dlls got 2 common exported functions " Importable" &"Linkage"

Almost correct. The first one is "ImportTable".

Let me make a silly guess, are those 2 functions working as the "entry point"?

Not exactly.

The ImportTable lists the modules to which the current module needs to link to, and when loaded entries in that table get filled with the requested modules Linkage table address.

The Linkage lists all the locations in the current module which can be accessed by other modules. Two of those relate to initialisation and termination.

So, between them they link everything together, like normal DLL imports and exports but done differently, a way which dates way back before there were such things as DLLs (i.e. before Windows).

There is some extra info at the top of the tables, to identify the module and which version of FS it is made for.

All of this is actually the part which is EXACTLY the same in C-written Gauges and documented in the FS Gauges SDK. So you could work things out from there. In fact your best first step would be to write a gauge and get it working as a gauge. As I said, it is only a DLL loaded through the Panels system instead of by the initial loader.

Regards

Pete

Link to comment
Share on other sites

Hi Pete,

I'm trying to build a plugin for FS9 also. Following your post I try to buid the Panels_SDK sample, using Visual Studio 2010 Express C++. I have some compilation problems:

gaugesdkpanel.jpg

Seems that this can only be done in pure C, or does not work in C + +, I do not know.

Can you show me some example of gauge made ​​in C + + that works?

What is the best IDE to do this?

Thanks!

Link to comment
Share on other sites

I'm trying to build a plugin for FS9 also. Following your post I try to buid the Panels_SDK sample, using Visual Studio 2010 Express C++. I have some compilation problems

Sorry, I can't really help. I've never used any of the SDK stuff, and I think VS Express is a lot different from VS Professional which I use.

However, whenever I have built a project and received a list of errors I've found the error messages quite useful, and just get to work eradicating each problem in turn till there's none left. Sometimes it's a matter of getting the build properties right, or the includes and LIB references. It's part of programming life I'm afraid. My biggest headaches seem to come when upgrading from one version of VS to the next. VS2003 to VS2005 to VS2008 to VS2010. Each one has caused reams of errors to appear in projects which previously compiled with no errors. It's a matter of working out why, for each, and fixing it.

Can you show me some example of gauge made ​​in C + + that works?

No, for three reasons

1. I've never actually written a gauge. I worked out my code by hacking and disassembling FS modules. I only found later that gauges were so similar.

2. I don't use C++, only C and ASM. I prefer ASM really, but C is acceptable. I don't like getting too far away from the machine level. I grew up as an engineering test programmer on mainframes.

3. Any example i could possibly find will fail on every compiling system except the one it was built for. Maybe it only needs a few tweaks to make it work, but it will still fail initially.

It doesn't really look like you've got many problems to solve according to that picture. Most look to be due to it seemingly not recognizing that "GAUGE_NAME" has been defined. I don't understand why though. Sorry.

What is the best IDE to do this?

Well, I suppose it would be the one Microsoft used to develop the SDK stuff. Does it say anywhere?

But you should be able to adjust things for any IDE, or at least any Microsoft one.

Regards

Pete

Link to comment
Share on other sites

Hi Pete, thanks for the answers. I got compile my gauge using the "makefile" and setup the project to compile with that.

Now I want to play a sound in the gauge. I try call the function PlaySound(L"C:\\Games\\FS2004\\Sound\\X1.wav", NULL, SND_ASYNC | SND_LOOP);

But, I hear only a beep, like a fail playing.

I see in others forum people talking to use "DirectSound SDK" or "Gaugesound.dll". But I do not want to put a module to simple play a sound.

And I leave a question: What is the easiest way to play a sound wave in a C Gauge?

Link to comment
Share on other sites

Now I want to play a sound in the gauge. I try call the function PlaySound(L"C:\\Games\\FS2004\\Sound\\ X1.wav", NULL, SND_ASYNC | SND_LOOP);

But, I hear only a beep, like a fail playing.

Sorry, I've no idea about "PlaySound", and do not recognise that L"...." structure. What's the L for?

Maybe PlaySound needs exclusive access to the sound device and cannot get it because FS has it too? Didn't you check for an error return, or GetLastError? Surely that's the first step to working out what is wrong?

I see in others forum people talking to use "DirectSound SDK" or "Gaugesound.dll". But I do not want to put a module to simple play a sound.

And I leave a question: What is the easiest way to play a sound wave in a C Gauge?

Sorry, I don't know. I added sound facilities into the Lua plug-in libraries in FSUIPC and WideClient and I used DirectSound for that, but I did that because I wanted to offer sound card selection and sound positioning in stereo and 5.1 sound systems. I've really no idea how to make sounds in any simpler way. The code I used was a re-use of similar stuff i did many years ago for an FS Module called "esound.dll".

You can play sounds through those added facilities in FSUIPC, by interfacing to FSUIPC and using the offsets for that facility. see the "FSUIPC SOUND INTERFACE" section of the latest FSUIPC for Programmers document. Of course if you used FSUIPC you'd be dependent upon users installing that too.

Regards

Pete

Link to comment
Share on other sites

Sorry, I've no idea about "PlaySound", and do not recognise that L"...." structure. What's the L for?

This work like a cast, withot that a have a erro: argument of type "const wchar_t *" is incompatible with parameter of type "LPCSTR"

Maybe PlaySound needs exclusive access to the sound device and cannot get it because FS has it too? Didn't you check for an error return, or GetLastError? Surely that's the first step to working out what is wrong?

You're probably right, FS has restricted access to the sound device.

Sorry, I don't know. I added sound facilities into the Lua plug-in libraries in FSUIPC and WideClient and I used DirectSound for that, but I did that because I wanted to offer sound card selection and sound positioning in stereo and 5.1 sound systems. I've really no idea how to make sounds in any simpler way. The code I used was a re-use of similar stuff i did many years ago for an FS Module called "esound.dll".

You can play sounds through those added facilities in FSUIPC, by interfacing to FSUIPC and using the offsets for that facility. see the "FSUIPC SOUND INTERFACE" section of the latest FSUIPC for Programmers document. Of course if you used FSUIPC you'd be dependent upon users installing that too.

I feel I need to study more about it, I am C # developer for 8 years and C language is a great paradigm for me. I will test the module "esound.dll"

ps. Pete, I think its incredibly your expertise with software development, I feel proud to ask questions with you, thanks!

Link to comment
Share on other sites

This work like a cast, withot that a have a erro: argument of type "const wchar_t *" is incompatible with parameter of type "LPCSTR"

This "PlaySound" needs wide characters? Most APIs have both ASCII and Wide Character variants, and the compiler chooses the correct one according to your compilation settings. For a module in FS you should probably really be compiling with normal single byte character mode. I suspect this might be the problem.

And you can cast a parameter by preceding is the (LPCSTR).

You're probably right, FS has restricted access to the sound device.

no, it cannot have as my FSUIPC sound facilities work okay. If it is due to access it will be that Playsound demans exclusive access and can't get it.

You should be able to work out which error it is by processing the error number! As I said, that is surely your first step!

I will test the module "esound.dll"

Why? That is very old now and obsolete -- I do not support it any more and it will not work in FSX. As I said, I put all of the Esound capabilities into FSUIPC. I pointed you to the documentation.

Regards

Pete

Link to comment
Share on other sites

I understand,

Right now I can not do a test on FS. But I read the documentation and understand that I must do something like this:

...	

#include "..\Header\FSUIPC_User.h"	

void playSound (path)
{
  DWORD dwResult;
  FSUIPC_Read(0x4200, 1, status, &dwResult);
  FSUIPC_Write(0x4208, 250, path, &dwResult);
  FSUIPC_Write(0x4204, NULL, NULL, &dwResult);
  FSUIPC_Write(0x4200, NULL, 1, &dwResult);
  while (FSUIPC_Read(0x4202, 1, status, &dwResult) == 1)
  {
  	Sleep(300);
  }
}

...

I put "NULL" in the parameters that do not know what to put.

Also I still read the post: http://forum.simflig...-sound-example/

Maybe can use this LUA sound.

Edited by rhpa23
Link to comment
Share on other sites

Right now I can not do a test on FS. But I read the documentation and understand that I must do something like this

No. the read of offset 4200 is for you to check that FSUIPC is able to accept your command . You must wait till that reads zero before doing the rest. You effectively have no such protocol at all in your code -- what is the point of reading 4200 if you take no notice of it? See?

Also this next bit is not good:

while (FSUIPC_Read(0x4202, 1, status, &dwResult) == 1)

{

Sleep(300);

}

I suspect that will hang, as you aren't testing any status, but the success or otherwise of the READ. Without a Process there's nothing done in the loop so it will simply crash or fail when the memory is full of your read requests.

I put "NULL" in the parameters that do not know what to put.

Er, like where? There's really no room for any "NULL"s here! You need to understand it all.

I think you need to look at some of the examples of interfacing to FSUIPC. You need to learn the interface first. The reads and Writes only accumulate requests in your program's memory. Only the Process call talks to FSUIPC. If you are using the libraries, then for an internal FS module or gauge you need to use the internal module library and the FSUIPC_Open2 call to connect, supplying your own memory for the transfers.

Additionally, note that the 3rd parameter in the FSUIPC_Read and _Write calls is the ADDRESS of the data (i.e. a pointer), not the data., so even that "status" entry you have above should probably be "&status" instead. I assume you intended that loop to wait until your sound has finished? But that is only uupdated when you ask for status. For instance, what if someone else starts a sound? You can't tell by simply reading 4202, you have to write your sound's ID first to 4204, with command 4, the "query status" command.

This interface is a sophisticated multiple sound + multiple client facility. You need to follow the written protocols for each operation, exactly as documented.

Regards

Pete

Link to comment
Share on other sites

[/i]This "PlaySound" needs wide characters? Most APIs have both ASCII and Wide Character variants, and the compiler chooses the correct one according to your compilation settings. For a module in FS you should probably really be compiling with normal single byte character mode. I suspect this might be the problem.

And you can cast a parameter by preceding is the (LPCSTR).

no, it cannot have as my FSUIPC sound facilities work okay. If it is due to access it will be that Playsound demans exclusive access and can't get it.

Pete, the "Playsound" work fine when I put ASCII Character. Your suspicions were right. Thanks again!

PlaySound(NULL, NULL, SND_ASYNC);	// Stop the sound
PlaySound(".\\Sound\\XY1.wav", NULL, SND_ASYNC | SND_LOOP);    // Play the sound

Link to comment
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...
 Share

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