javiercuellar Posted January 25, 2010 Report Posted January 25, 2010 Me again :oops: Now that I'm able to create a menu in add-ons, is it posible to create submenus inside this one? Thanks
Pete Dowson Posted January 25, 2010 Report Posted January 25, 2010 Now that I'm able to create a menu in add-ons, is it posible to create submenus inside this one? FSUIPC doesn't support that at present, though SimConnect does, so it would be a possible extension I suppose. Really the FSUIPC option is a carry-over from the previous FSUIPC3 versions, and only provides that level of compatibility so that earlier apps could work with FSX without change. If it is a serious need I could probably work out a way of building it onto the current FSUIPC3 facility, but it isn't an instant thing. I'd need to do a bit of research before I decided. Regards Pete
javiercuellar Posted January 25, 2010 Author Report Posted January 25, 2010 Thanks Pete. I'll keep the application as external. Maybe you could put this in the "It would be nice to.." list. Thanks for your excellent support.
Pete Dowson Posted January 25, 2010 Report Posted January 25, 2010 Maybe you could put this in the "It would be nice to.." list. Actually i just had a quick look and it may not be hard to do. What about a design like this: Having already setup the main menu, write this to 0x2FE0: Byte 0 = 0x80 + slot number of main entry, as before Byte 1 = Response value (any non-zero value 1 - 255) Bytes 2-31 = The zero-terminated string for the submenu entry SimConnect limits you to a max of 16 submenus. There are no further sub-levels. When the user selects the submenu FSUIPC will fill in byte 3 of the slot with the "Response value" provided. Naturally you don't get notified when the main menu entry is selected when there are submenus. What do you think? I reckon I could add that this week (FSUIPC4 only, I'm not adding it to FSUIPC3). Regards Pete
javiercuellar Posted January 25, 2010 Author Report Posted January 25, 2010 :shock: You are amazing !!!! That will be great!!!! :wink: Only one thing. Byte 1 = Response value (any non-zero value 1 - 255) Actually Byte 0 is slot number Byte 1 to 31 is menu name. Wouldn't the new design produce a conflict with already created applications?
Pete Dowson Posted January 25, 2010 Report Posted January 25, 2010 Actually Byte 0 is slot number Byte 1 to 31 is menu name. Not for the submenu. I need to use the second byte to determine the Response value. Please study it again. Wouldn't the new design produce a conflict with already created applications? No, because the maximum slot number is 56 (there are only 56 slots). The top bit (0x80 added is the flag which tells FSUIPC that this is for a submenu to be added to an already created menu entry. You have to refer to an already set menu slot. Please study the proposal again and think about it. It is so easy to do I've almost finished and will be testing it later! Regards Pete
javiercuellar Posted January 25, 2010 Author Report Posted January 25, 2010 Rgr. I'll be waiting for this. Thanks
Pete Dowson Posted January 26, 2010 Report Posted January 26, 2010 I'll be waiting for this. Okay. All done and dusted. Download 4.578 from the Updates announcement. Here's the documentation: 11. Facilities have been added to allow sub-menus to be added to menus created in the "Add-Ons" menu via the use of FSUIPC offset 2FE0 and the Hot Keys table at 3210. Full documentation will be included in the next SDK update, but meanwhile the included "MenuDemo.lua" plug-in and the following notes should be sufficient to allow full use:Having already setup the main menu, as already documented, write this, in one write, to 0x2FE0: Byte 0 = 0x80 + slot number of main entry, as before (i.e. 0 for 3210, 1 for 3214 etc. Remember the max is 55, there being 56 slots). Byte 1 = Response value (any non-zero value 1 - 255). This is merely a value for you to test so you know which submenu was selected. Bytes 2-31 = The zero-terminated string for the submenu entry There's a limit of 16 submenus per menu entry (imposed by SimConnect), and there are no further sub-levels. When the user selects the submenu FSUIPC will fill in byte 3 of the slot with the "Response value" provided. Naturally you don't get notified when the main menu entry is selected when there are submenus. You can remove a submenu by doing the same as above but with a null string for the submenu entry (i.e. a single zero byte). The included Lua plug-in demonstrates addition and deletion of submenus, as well as basic things like adding and removing the main menu, detecting which entry was selected, and maintaining the menu against the imposed timeout. Have fun! Regards Pete
javiercuellar Posted January 26, 2010 Author Report Posted January 26, 2010 I have no words for this. Only thanks you very much :wink: I'll implement it this night!! :D
javiercuellar Posted January 27, 2010 Author Report Posted January 27, 2010 Hi Pete, Just to let you know that finally it is working perfectly!!! :D It took me a long time, because in vb.net I have to write a value in local variable and then send it to FS calling FSUIPCConnection.Process(). It looks simple, but it is very important the exact moment when the values should be sent. For anyone facing problems , like me, the algorithm is: Write to free slot value &HFFFF (ex. &H3210) send to FS Write byte 1 of &H2FE0 with slot number (ex. 0 if using &H3210) send to FS ' For menus Write Menu title to byte 1 - 31 of &H2FE0 send to FS 'For submenus Repeat Write response number to byte 1 of &H2FE0 send to fs ----> here I had the headache Write to byte 1 of &H2FE0 &H80 + slot number write submenu title to byte 2 - 30 of &H2FE0 send to fs until no more submenus In a Timer control each 10 sec write &HFF to byte 3 slot (with previous ex. it will be &H3213
Pete Dowson Posted January 28, 2010 Report Posted January 28, 2010 Write to free slot value &HFFFF (ex. &H3210) send to FS Write byte 1 of &H2FE0 with slot number (ex. 0 if using &H3210) send to FS ' For menus Write Menu title to byte 1 - 31 of &H2FE0 send to FS That isn't right in two ways. First the slot number goes in Byte 0. The title starts in byte 1. Second, you should write the whole lot in one write, because FSUIPC will be taking the action of adding the string to the menu system as soon as it sees you writing to 2FE0. If it appears to be working for you you are just lucky. It will be very time critical. The correct way to do it is as shown in the documentation. Declare your title string as, say "XMy title string", i.e. with the extra character at the front, then, before writing that string, alter the first character to the binary number of the slot. Maybe in VB.NET you would have to do this by having the string declared as a BYTE array, so you can address byte [0] specifically./ 'For submenusRepeat Write response number to byte 1 of &H2FE0 send to fs ----> here I had the headache Write to byte 1 of &H2FE0 &H80 + slot number write submenu title to byte 2 - 30 of &H2FE0 send to fs until no more submenus Same errors here. The 128 + slot number goes in byte 0 not 1 or you overwrite the response. You should write all in one write again. Your title will have two preceding characters "XYMy Submenu title" and you replace X and Y before writing. Bytes [0] and [1]. In fact, because your response number is arbitrary -- your choice of any value from 1 to 255 -- you might as well make it an ASCII character, like 'A'. in which case you only have the Byte[0] to overwrite, in "XAMy Submenu Title" If you are getting away with the code as you are stating it you are very lucky. It isn't designed to work that way. did you look at the Lua example I provided? Lua is quite Basic-like in many ways -- more restrictive in some, more flexible in others. Regards Pete
javiercuellar Posted January 28, 2010 Author Report Posted January 28, 2010 First the slot number goes in Byte 0. The title starts in byte 1. Upsss, type mismatch. I had it the correct way. :? Declare your title string as, say "XMy title string", i.e. with the extra character at the front, then, before writing that string, alter the first character to the binary number of the slot. Maybe in VB.NET you would have to do this by having the string declared as a BYTE array, so you can address byte [0] specifically./ Yes, I tried that, but I can't manage to use it that way, because if declare as byte array, then I need to write each byte individually (that is each letter). Using a conversion function string to bytes (GetBytes) will also give me more problems, because the array initially declare as 30 byte, will change to the size of the string. Same errors here. The 128 + slot number goes in byte 0 not 1 or you overwrite the response. Same type mismatch (copy paste from the other one). If you are getting away with the code as you are stating it you are very lucky. After applying the theory it didn't work, so I start with trial and error and finally made it work, so I guess I'm lucky. did you look at the Lua example I provided Yes, but the difference is that lua writes directly to FS, and in vb.net I have to write locally and then send to FS. I know that it sounds ilogic, but, belive me, that make a lot of difference. In any case, now it works, after 2 days fighting with 20 lines of code. Soon I'll try to look at it again and let you know, if that is ok for you? Thanks.
Pete Dowson Posted January 28, 2010 Report Posted January 28, 2010 Yes, I tried that, but I can't manage to use it that way, because if declare as byte array, then I need to write each byte individually (that is each letter). Using a conversion function string to bytes (GetBytes) will also give me more problems, because the array initially declare as 30 byte, will change to the size of the string. Ugh. What a horrible language it must be! Two points then: 1. It doesn't matter how many bytes you write, provided no more that the 32 (from offset 2FE0), and the last one is zero. It is the zero with terminates the title string, not the end of the area provided for it. 2. If you must write the parameter byte(s) and string separately, it would be safer to write the string first, then the "slot" byte (0), because it is writing the slot byte which triggers the action. Of course, as I said, for submenus the "response byte" can be part of your title string. Just use distinct letters or number characters so you can distinguish the response when you receive it. Regards Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now