FreePIE MIDI input, some questions

Official forum for open source FreePIE discussion and development.
Post Reply
Gruso
One Eyed Hopeful
Posts: 1
Joined: Sat Jan 07, 2017 11:30 pm

FreePIE MIDI input, some questions

Post by Gruso »

I'm attempting to map a MIDI controller to various Vjoy inputs (analogue & digital) but hitting a brick wall. I have read through these:

http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=20537
http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=21436
https://github.com/AndersMalmgren/FreePIE/issues/81

From the above, I am using a script that allows me to use a slider on the MIDI controller as a throttle in flight sims:

Code: Select all

def update():

	vJoy[0].slider = filters.mapRange(midi[0].data.buffer[1], 127, 0, 17873, -17873)
	
if starting:
	midi[0].update += update
This works nicely on its own. However, any other inputs on the MIDI controller also affect the output (ie. hitting a MIDI key or tweaking a knob also makes my throttle control jump around). I guess this is because the above code is looking at the entire data buffer of the device, not a single channel.

The slider is a volume control, which is MIDI CC 07. So I am trying to get the script to listen to that only, for example:

Code: Select all

vJoy[0].slider = filters.mapRange(midi[0].data.buffer[1] == 07, 127, 0, 17873, -17873)
or with additional parentheses:

Code: Select all

vJoy[0].slider = filters.mapRange((midi[0].data.buffer[1] == 07), 127, 0, 17873, -17873)
But with any change I make, the output ceases. If I only wanted to use the slider I wouldn't mind, but I would also like to map some button inputs. Can anyone help with the correct syntax?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: FreePIE MIDI input, some questions

Post by CyberVillain »

Hi,

I think you want to look at the data.status and data.channel properties too
Thermal
One Eyed Hopeful
Posts: 1
Joined: Sat Mar 04, 2017 1:24 am

Re: FreePIE MIDI input, some questions

Post by Thermal »

I think the magic you want is something like this:

Code: Select all

    if (midi[0].data.buffer[0] == 5):
        vJoy[0].x = filters.mapRange(midi[0].data.buffer[1]), 127, 0, 17873, -17873)

    if (midi[0].data.buffer[0] == 6):
        vJoy[0].y = filters.mapRange(midi[0].data.buffer[1]), 127, 0, 17873, -17873)
Post Reply

Return to “FreePIE”