Blake Buhlig Posted June 16, 2021 Report Posted June 16, 2021 I wrote a Python module to generate FSUIPC button mappings, once I realized the complexity of them that I was moving toward was going to make it hard to directly look at/manipulate the INI. For example usage and details, see https://github.com/bbuhlig/fsuipc-contrib/blob/main/gen_ini.py . Actually using it would require a suitable Python >=3.7 environment. The Python module consists of a number of files in my https://github.com/bbuhlig/fsuipc-contrib repo, so I recommend downloading or cloning the entire repo. Once setup just run gen_ini.py without arguments to print out an example Buttons and Buttons.twin section suitable for copy/pasting into an FSUIPC7.ini file.
John Dowson Posted June 26, 2021 Report Posted June 26, 2021 @Blake Buhlig Thought I would take a look at this. I have copied the Controls List for MSFS Build 999.txt file and mobiflight-msfs2020_eventids.cip.txt file to the root folder, but am now getting the following error when trying to run: Quote Traceback (most recent call last): File "C:\Users\jldow\Downloads\fsuipc-contrib-main\gen_ini.py", line 95, in <module> MBFCtrl = CreateControls("MBFCtrl", File "C:\Users\jldow\Downloads\fsuipc-contrib-main\fsuipcini\controls.py", line 55, in CreateControls with open(fn,'r') as ctrls_ifh: FileNotFoundError: [Errno 2] No such file or directory: 'custom_ctrls_info.tsv.txt' What is the custom_ctrls_info.tsv.txt file and how can I generate it? Are there any other files I need? Is there a config file I can update with the file locations - or any general usage instructions? Thanks, John
Blake Buhlig Posted June 27, 2021 Author Report Posted June 27, 2021 (edited) Hi @John Dowson, thanks for checking this out. On 6/26/2021 at 7:09 AM, John Dowson said: What is the custom_ctrls_info.tsv.txt file and how can I generate it? I tried to document the background on that file at line 88 of gen_ini.py. The file is supposed to be a mapping between control IDs and names for custom MobiFlight events, generally formatted like what you provide for the standard controls in Controls List for MSFS Build 999.txt. The python library function I wrote tries to parse files of that general columnar format into enums, such that whatever python button mapping code one might write can easily reference the controls by name. For the purposes of demoing this, I attached the version I came up with. I created it by a couple of scripts. First, cip_to_evt.py converts the full MobiFlight CIP file to a set of custom *.evt files. Second, gen_custom_ctrls_info.py parses those *.evt files, along with the resulting FSUIPC7.ini EventFiles section , to derive the corresponding custom control IDs that would need to appear in FSUIPC7.ini button mappings. Additionally, I noticed the CIP file had the controls organized into "groups", and I thought that was just useful information to have in a third column in the info file, therefore the gen_custom_ctrls_info.py file also reparses the CIP file to extract the group info. In wanting to keep it easy to import into a spreadsheet even with a third column, I delimited the columns with tabs rather than spaces, which is why it has .tsv -- tab-separated values -- in the filename. Note the attachment should only be considered a demo as it is based on my own setup. Specifically for the assignments it generates to actually work properly for anyone, they would need to have setup a proper custom control config (e.g. WASM module installation), account for any other custom *.evt files they might have installed, add in various lua modules I reference that e.g. map fast rotary encoder spins to virtual button presses, etc. On 6/26/2021 at 7:09 AM, John Dowson said: Are there any other files I need? Once the attachment is copied in, gen_ini.py will probably get past that point then die at line 117 looking for file fsuipc_controls.txt. This one is intended to be a parsable file of similar format as the other two txt files, to generate enums for all the special controls documented in the Advanced Users Guide, pp.26-32. I generated that file by manually copy/pasting the PDF text, manually removing page numbers that were embedded in the copy, and manually replacing various copied Unicode characters that Python was bombing out on e.g. the curly quotes. Unlike the custom controls file, I wouldn't expect this file to differ between users so I could distribute it, but it is a direct derivative from the documentation so I wanted to get your permission first. On 6/26/2021 at 7:09 AM, John Dowson said: Is there a config file I can update with the file locations - or any general usage instructions? I wasn't planning on a config file as such. The essential contribution I'm offering is the library under the fsuipcini directory, to be used by a python coder in generating sections of the FSUIPC ini. The gen_ini.py is my attempt in using the library to generate button mappings for my own setup, and I contributed it only as a demo usage of the library. Certainly one could adapt it for different file locations, paths etc., extend it to take a config file etc., but even after dealing with the file path issues I expected someone else would want to tweak the btnmap() calls throughout to map whatever control to button mappings particular to their own setup. Your attempt to use this does make me recognize I need to provide more out of the box to get gen_ini.py to run even as a demo, which in my original post I incorrectly suggested it would. So especially if you give me permission to add fsuipc_controls.txt, I can do so to lower the entry barrier for people to do that. As far as other general usage instructions, at this point I can only offer the code itself such as it is, but over time and if enough interest I can add more documentation. On that note this is definitely still under development and likely will continue to be until I ultimately come up with button assignments for my Alpha/Bravo-based setup that I'm satisfied with. I contributed it early both trying to get a feeler from people whether a framework like it could be useful -- e.g. are there python coders out there with complex button assignment needs? -- or even more fundamentally get feedback whether what this is trying to do might already exist in some other form. Another thing occurring to me is, maybe people could be interested in the actual assignments I come up with tailored to the Alpha and Bravo hardware. I'm happy to contribute that once I have it but as mentioned, I'm very much still working on it. I expect that contribution would mainly be in the form of output from whatever my final gen_ini.py is, though maybe with the source also included as a reference. Appreciate comments, thanks! Edited June 27, 2021 by Blake Buhlig Removed attachment, to be re-uploaded with license info
John Dowson Posted June 27, 2021 Report Posted June 27, 2021 8 hours ago, Blake Buhlig said: So especially if you give me permission to add fsuipc_controls.txt, Of course, no problem with this. Thought I'd take a look as this looked quite interesting. I'll go through your comments in detail next week and take a look at the code areas you mentioned. I'll let you know how I get one. Regards, John
Blake Buhlig Posted June 27, 2021 Author Report Posted June 27, 2021 Very well, thank you. I realized I should add the Mobiflight MIT license to the TSV file since it too is a derivative product. Once that is done I will upload both to GitHub.
Blake Buhlig Posted June 28, 2021 Author Report Posted June 28, 2021 @John Dowson, I uploaded a new version with which I was able to get it to run quickly from a fresh clone. Let me know any issues. Thanks, -Blake C:\Users\bb-mi\test>git clone https://github.com/bbuhlig/fsuipc-contrib Cloning into 'fsuipc-contrib'... remote: Enumerating objects: 92, done. remote: Counting objects: 100% (92/92), done. remote: Compressing objects: 100% (52/52), done. Receiving objects: 100% (92/92), 89.98 KiB | 1.23 MiB/s, done. remote: Total 92 (delta 51), reused 79 (delta 38), pack-reused 0 Resolving deltas: 100% (51/51), done. C:\Users\bb-mi\test>cd fsuipc-contrib C:\Users\bb-mi\test\fsuipc-contrib>copy "..\..\OneDrive\Documents\FSUIPC7\Controls List for MSFS Build 999.txt" . 1 file(s) copied. C:\Users\bb-mi\test\fsuipc-contrib>python gen_ini.py [Buttons] PollInterval=25 ;a340 ButtonRepeat=20,10 ;a340 IgnoreThese=B.12, B.13, B.21, B.22 ;a340 1=PA,12,C67175,0 ;a380 2=PA,13,C67174,0 ;a381 3=PA,14,C67173,0 ;a382 <snip>
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