Midi And Freepie setButton
Posted: Sun Aug 13, 2017 12:37 pm
Hi all, I've been digging into py and freepie and the use of MIDI controllers.
I'm trying to get a vJoy button to work when I press a button on my midi controller. And I'd like to keep it pressed for as long as I hold the button. I'd also like to have a 'latched' option that will keep the button pressed without keeping the button on the controller pressed, when 'latched == true'
I'm very sorry my knowledge of py is very little.. This is what I come up with, but obviously it doesn't work.
Also I'd like to know if there is a better way, I will be using around 50 buttons..
I'm trying to get a vJoy button to work when I press a button on my midi controller. And I'd like to keep it pressed for as long as I hold the button. I'd also like to have a 'latched' option that will keep the button pressed without keeping the button on the controller pressed, when 'latched == true'
I'm very sorry my knowledge of py is very little.. This is what I come up with, but obviously it doesn't work.
Also I'd like to know if there is a better way, I will be using around 50 buttons..
Code: Select all
def update():
if (midi[0].data.buffer[0] == 71):
vJoy[2].x = filters.mapRange(midi[0].data.buffer[1], 127, 0, 17873, -17873)
if (midi[0].data.buffer[0] == 74):
vJoy[2].y = filters.mapRange(midi[0].data.buffer[1], 127, 0, 17873, -17873)
if (midi[0].data.buffer[0] == 24) and (midi[0].data.buffer[1] > 120):
vJoy[2].setButton(0,1)
if latched == False:
vJoy[2].setButton(0,0)
diagnostics.watch(midi[0].data.channel)
diagnostics.watch(midi[0].data.status)
diagnostics.watch(midi[0].data.buffer[0])
diagnostics.watch(midi[0].data.buffer[1])
if starting:
latched = False
midi[0].update += update