AndersMalmgren / FreePIE

Programmable Input Emulator
650 stars 144 forks source link

Get MIDI value from a specific slider or dial #87

Closed hannibaltexter closed 8 years ago

hannibaltexter commented 8 years ago

I've seen this script

filters.mapRange(midi[0].data.buffer[1], 0, 127, -17873, 17873)

This grabs the value for any button on the midi input. I'd like to know if I can get a value for a specific slider or dial. I can't seem to find what I'm looking for online.

If possible I'd like to grab 3 different midi inputs and assign them to vJoy[0].x, vJoy[0].y and vJoy[0].slider.

Thank you for you help

hannibaltexter commented 8 years ago

Here is an incomplete solution:

vJoy[0].slider = midi[0].data.buffer[0] == 1 and filters.mapRange(midi[0].data.buffer[1], 0, 127, -17873, 17873)

New issue is, once I press another button on the midi controller, the previous value of vJoy[0].slider changes back to 0. This is due to

if starting: midi[0].update += update;

not sure about how to fix that. I will update as I progress.

hannibaltexter commented 8 years ago

Final Solution:

Before if starting: I added the following:

if midi[0].data.buffer[0] == 1: Elevator_Trim = midi[0].data.buffer[0] == 1 and filters.mapRange(midi[0].data.buffer[1], 0, 127, -17873, 17873) vJoy[0].slider = Elevator_Trim;

Now I just have to add an if statement for each control I want to use.