maartentamboer / X-Touch-Mini-FS2020

Control FS2020 with a Behringer X-Touch Mini
https://dev-tty.nl/X-Touch-Mini-FS2020/
MIT License
59 stars 19 forks source link

JSON Schema for config file #30

Closed tedb closed 3 years ago

tedb commented 3 years ago

Hi @maartentamboer, I was so pleased to find the X-Touch-Mini-FS2020 project. It was exactly what I was looking for to use this MIDI controller to add a few extra knobs to my yoke. Thank you for publishing and maintaining this project!

When getting started with writing a custom config file, I had a little trouble understanding the available options and required structure of the config. After reading the code and digesting the MSFS SDK docs, I managed to figure it out (and it's quite elegant!).

To make it easier for future tinkerers, this PR includes a proposed JSON Schema for your consideration. Using the schema allows tools like VS Code's IntelliSense to auto-complete the available options, and validate the config file's contents. Note that its use is optional and would not prevent a non-passing file from being read by the Python code.

The schema was written based on my reading of the Python code that consumes the JSON object in the config file. The lists of "event IDs" and "simvars" are extracted from the MSFS 2020 SDK documentation HTML, using XPath.

I would love any comments you might have on this, especially anything I may have overlooked or ways to improve it.

maartentamboer commented 3 years ago

That's a really cool addition. What do you think about adding the $schema directly in the config_default and config_a320.json?

{
  "$schema": "./config.schema.json",
  "version":
  {
    "major": 1,
    "minor": 0,
    "patch": 0
  },
  "encoders": [
    {
      "index": 1,
      "event_up": "KOHLSMAN_INC",
      "event_down": "KOHLSMAN_DEC",
      "event_press": "BAROMETRIC"
    },
]
tedb commented 3 years ago

Hi there Maarten, thanks for the quick reply!

What do you think about adding the $schema directly in the config_default and config_a320.json?

Yes, I think that's a great idea. I've made this change!

maartentamboer commented 3 years ago

Looks great, thanks for contributing and the sponsor 😃

I'll create a new release this weekend after I've hopefully fixed https://github.com/maartentamboer/X-Touch-Mini-FS2020/issues/29