c0redumb / midi2vjoy

MIDI to virtual joystick mapping
BSD 2-Clause "Simplified" License
96 stars 31 forks source link

Removed dependence on pre-defined axis / button IDs in favour of using the config file. #16

Open spanner-uk opened 3 years ago

spanner-uk commented 3 years ago

Modified the logic to use the config file to determine if the input is an axis or a button instead of pre-defined key IDs.

This should mean that any MIDI Control Change (CC) ID can be used, making the tool completely cross-device compatible.

This change was required for custom axes / buttons defined in the Novation LaunchPad Mini Mk3 control software where CC messages on other channels were entirely ignored by the midi2vjoy application and CC buttons on channel 1 were all incorrectly handled as axes, when they can also be buttons.

Note: I do not know if a 128 key ID is a special midi value so have retained the 'button off' logic.

The '144' key ID appears to exclusively represent buttons because it is the default mapping for note keys A-G on octaves 1 - 8. It's just that '176' does not guarantee that the Control Change (CC) is due to an Axis input, it is just a CC input on channel 1 (and 177 is channel 2 etc.)

spanner-uk commented 3 years ago

On review, the 128 key handling is redundant so I have removed it. It will be handled like any other non-axis button press so the values will get sent without the extra if statement.

spanner-uk commented 3 years ago

I have extended this further to make it even more device agnostic by filtering out MIDI clock signals (signal 248) and handling devices that signal a button depress on an alternative channel to the original button (which is somewhat of a hack but works well enough and doesn't affect devices that don't have this issue).