1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating FSX Modules??

Discussion in 'Tools programming' started by Manuel Ambulo, 15/10/06.

  1. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Hi,

    Just wanted to know if anybody had been working in creating a FSX module file (.DLL)..just wanted to know if the normal method for create a module (as it was in previous versions like FS2004)..still works with FSX?....(i mean it is just necessary to update the version number, 0x1000 (FSX) instead of 0x0900 (FS9)...in the version field...or all is all totally different in FSX?...the linking system is different?...:confused:

    Best Regards,

    Manuel Ambulo

    NOTE: (Sorry by my bad english...)
  2. scruffyduck

    scruffyduck Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    17/9/05
    Messages:
    23,248
    Country:
    wales
    Hi Manuel

    I don't know the answer to that :eek: Pete Dowson has clearly done it with FSUIPC4.

    I have not built modules in the past but only external programs.

    Hopefully someone can answer :)
  3. MachTwo

    MachTwo

    Joined:
    29/9/06
    Messages:
    8
    Country:
    unitedkingdom
    Hi Manuel,

    The SDK contains examples showing how to add a manu/sub menus to FSX using SimConnect. It’s a little easier than before :)
  4. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Thanks, MachTwo and also thanks scruffyduck, didnt knew that the SDKs also comes with samples to add menus. And yes, when creating modules for FS2004 it was a little bit more tricky to add a menu entry, it was to be done a lot of things before....and now things are more easier...:eek: ....its nice to now that :)

    Best Regards,

    Manuel Ambulo
  5. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    So are you okay with making FSX modules now?

    There's no "Linkage" or "ImportTable". All that stuff has gone. FSX's own modules use standard exports and imports now. It's a bit annoying as it makes them messier to hook (but not impossible of course).

    For an FSX-loadable DLL you need only to put details in the DLL.XML file, as described in the SDK, then, for SimConnect you need to export, as C procedures (not mangled C++ ones), a "DLLstart" and a "DLLstop". These are your replacements for the old Initi and De-Init links.

    Oh, you'll need a manifest too -- the Simconnect.h contains that. Using VS2005 it is easy to get that embedded in your DLL, for tidiness.

    Okay?

    Pete
  6. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Hi,

    Ohh...so no "Linkage", neither "ImportTable" ..well thats is a big change compared to old method to hook to the FS, mm....when you mean export "C" procedures you mean to use like (for example):

    extern "C" __declspec(dllexport) DLLstart();

    for export the "DLLstart" and "DLLstop"..right?....(please correct me if im wrong...)

    So, if there is no "Linkage", neither "ImportTable", that means i cannt access TokenVariables (just for read..variables) from my DLL (not gauge), instead then i need to use SimConnect?..(this is not problem for me), just asking, because i already had a project of a FS module for FS2002/2004...that extracts data using Token Variables and if they arent accessable in FSX, then i may need to change the code so it can use SimConnect to extract the required data...

    And about the manifest, it will be included in my DLL if i just do:

    #include "SimConnect.h"

    ?? using my VC++ 6.0?, or it needs another special thing to do? (I have the old Visual Studio 6.0)...

    Thanks, Pete, (sorry by too much questions...lol..:) ),

    Best Regards,

    Manuel Ambulo
    Last edited: 20/10/06
  7. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    LoL,...I found an answer for my own question...:D ....(in the SimConnect SDK), about the DLLStart and DLLStop function...i need to create a definition file (*.def)...using Visual C++ 2005, for export those functions...

    And also, now, that i had downloaded and installed Visual C++ 2005 Express Edition....i found another answer for the other question about the manifest...found that Visual C++ 2005 itself embed the manifest inside of the SimConnect.h, everytime i re-build the project....:eek:

    But there is still a mistery or question for me...that if there are Tokens variables available in FSX, and if there is no Linking system....how they are accessed by the gauges in FSX?....as in the past thru the IMPORT_TABLE it was done that,.......i mean you specified there the ID of the PANEL.DLL FS Module and then you could import that data (from the PANEL.DLL) directly to your FS Module.....Anyway im using now SimConnect to request and set data....so im not worried about that too much........but..this is a question that will be keep in my mind for a while...like HOW DO GAUGES ACCESS TOKENS (GAUGES = *.DLLs but with another extension --> *.GAU)...IF THERE IS NO LINKING SYSTEM...:confused:...<---(Mistery for me)...lol

    But anyways, thanks guys, by the help....:)

    Best Regards,

    Manuel Ambulo
    Last edited: 20/10/06
  8. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    You can use the Panels interface too. Inlcude the relevant bits if Gauges.h, and export a pointer to a PANELS structure called "Panels", thus:

    EXTERN_C __declspec(dllexport) PANELS *Panels;

    When Simconnect loads your module it will fill that pointer in for you, and off you go ...

    I don't think so, but I don't know. I bought VS2005 before I started. I think you will need to adapt the sample manifest file that comes with the SimConnect SDK, name it as your DLL but with .manifest on the end (after the .dll), then embed it into your DLL as resource type 2 using the manifest tool (MT.EXE) which you can get from the Microsoft site. I've a feeling you might have to get the entire 1Gb platform SDK to find it these days though.

    Regards

    Pete
  9. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    Ah .. just noticed your second post ...

    Yes, that's much easier!

    Gauges are a bit different in FSX I think. I don't think they are loaded by or need SimConnect, though they can use it.

    Anyway, you'll find the way to use the PANELS.DLL facilities in my last message.

    Regards

    Pete
  10. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Wow, i didnt knew that (very interesting)...that..Tokens Variables can be accessed by normal DLLs (not only gauges)......because (before posting here...), i took a brief look at the FSX Panels SDK and there is a C++ project sample (of a gauge) that seems like to be the same C++ code sample used in the FS2004 Panels SDK....and in the updated Gauges.h file, they seems they still use the old linking system....so that kept me thinking...until now....lol :) (Thanks)


    Yes, FSX's Gauges a bit different from those used in FS2004..maybe because the old linking system was used for so long....we were like use to see the same system (version after version) then suddenly (not instantly,... but is like something new...never seen before) it changed...... :eek:

    THANKS,

    Best Regards,

    Manuel Ambulo
  11. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    So, then for create a single module compatible with FS8, FS9 and FSX, i have to export all these functions at same time:

    ImportTable (used by previous FSs)
    LinkAge (used by previous FSs)
    DLLStart (used by FSX)
    DLLStop (used by FSX)
    Panels (Panels interface in FSX)

    Best Regards,

    Manuel Ambulo
  12. karijno

    karijno

    Joined:
    17/10/06
    Messages:
    15
    OK... thanks.... but if i use PANEL *Panels when i try to write and compile
    Panels->execute_calculator_code (str, &answer, NULL, NULL);
    give me an error

    Thanks Karijno
  13. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    But the error that you receive is after compiling?..or while running the DLL in FSX?

    Best Regards,

    Manuel Ambulo
  14. karijno

    karijno

    Joined:
    17/10/06
    Messages:
    15
    After that i compile it....!!!!!! :) Pete help!!!!!!!!!!
  15. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    You are using C or C++?

    What is the error exactly?

    If the PANELS structure is included (from the Gauges header), which I assume it must be as you have a pointer to it defined as Panels, and if that structure has an entry for

    (*execute_calculator_code )( ...)

    (does it?) then provided your parameter types match the compiler should be happy enough.

    So check back. Does the PANELS definition include that function? The one I'm using doesn't. If so do they parameter types match?

    The clue should be in the error you are getting. Usually the compilers are pretty good at saying what is wrong.

    Incidentally trhe only calls in PANELS I've ever used are

    void (FSAPI *initialize_var_by_name)( PMODULE_VAR module_var, PSTRINGZ name );
    void (FSAPI *lookup_var)( PMODULE_VAR module_var );

    and even "initialize" isn't used these days.

    Regards

    Pete
  16. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Yep, Im agree with Pete, i think that the clue is in the compiler...as it is very hard to say what is wrong as many things can cause an error (i mean many possible things....even a little word mistake can produce many errors...lol...:) ), so if you may post what does exactly the compilers says...or what's the exact error, it would be (i think..or maybe)..more easy to tell what is going wrong...so we can help you better.


    Yes, Pete, it is a new function added to the PANELS structure in the new updated "gauges.h" of the FSX...the function looks like this in the PANELS structure:

    BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);


    Me too, from the PANELS structure (in FS8 and FS9)..i used to use more those two functions (to access Tokens)...i never had used the others..:(


    I also have a little question....in the FSLINKAGE part (at the beginning of the PANELS structure, you set the version of the FS to 0x1000 right? (FSX) <---that's maybe a stupid question (sorry..lol)...but just to be sure if i have to put 0x1000 or can i also leave it as 0x0900 (FS9)?..or it is not needed to set the version of FS?...and....the pointers to:

    void (FSAPI *ModuleInit)(void); \
    void (FSAPI *ModuleDeinit)(void); \

    I need to leave them as NULL both?..as you know that there is no linkage...and those functions were replaced by the new DLLStart and DLLStop.

    (Sorry by asking those basics questions), :eek:

    Best Regards,

    Manuel Ambulo
  17. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    None of that part of the PANELS structure is used for a SimConnect client. I wouldn't write to any of it at all if I were you. Don't forget that the data that Panels points to isn't in your module in any case, it's something SimConnect had derived for you. It may even be common to all SimConnect clients.

    The PANELS pointer is filled in by SimConnect when your DLL is loaded just so you can access the procedures in the structure. All that other stuff is to do with the old pre-FSX methods of loading and initialising/ending modules which doesn't apply now.

    They may still be used in the Gauges side of things. I don't know whether there have been changes there or not. Simconnect doesn't load those.

    Regards

    Pete
  18. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Thanks, Pete, i was forgetting that the PANELS pointer is pointing to somewhere OUTSIDE of my module and writting on it (example: in the FSLINKAGE part or somewhere else in the structure)...may crash the FS or do something unexpected...so i will just export it and like i say: "dont touch it" (write or read on it)...until my module got fully loaded by SimConnect. So then, after loading, i can use the "initialize_var" and "lookup_var" functions for access and read the tokens. :)

    Hey, karijno, did you solved the compiler's problem?...(i mean did you found the solution for the error?)...:confused:

    Best Regards,

    Manuel Ambulo
  19. karijno

    karijno

    Joined:
    17/10/06
    Messages:
    15
    Hi Manuel and Pete,

    sorry but i was out of city for that period . I always have the same problem.
    When i try to compile my code , VS tell me that i have mismatch a "(" bracket in my method call i explain :

    i have declare a (....PANEL * pan) external in gauges.h
    in my .cpp file i included gauges.h
    in my code i used in this way:
    - pan->execute_code_calculator("blablabalbalb", &answer, NULL, NULL);

    at this point compiler tell me that i have mismatch a "(" bracket .

    Have any ideas?!?!?

    Thanks a lot

    Fabio
  20. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom

    First, note that the PANELS * export must be named "Panels" otherwise SimConnect will not find it and fill it in. "Pan" isn't right.

    Second, there must be an error some place in the definition of the PANELS structure, so let's see the definition of your PANELS * and the PANELS structure itself.

    Regards

    Pete

Share This Page