What I figured out so far is that this code will make the vJoy button to be held:
Code: Select all
if (midi[0].data.buffer[0] == 4) and (midi[0].data.buffer[1] == 127):
vJoy[0].setButton(4,True)
else:
vJoy[0].setButton(4,False)
Thanks in advance!
Code: Select all
if (midi[0].data.buffer[0] == 4) and (midi[0].data.buffer[1] == 127):
vJoy[0].setButton(4,True)
else:
vJoy[0].setButton(4,False)
Code: Select all
def update():
global toggle
if (midi[0].data.buffer[0] == 4) and (midi[0].data.buffer[1] == 127):
toggle = 1
if starting:
midi[0].update += update
toggle = 0
if (toggle == 1):
vJoy[0].setButton(4,True)
toggle = 0
else
vJoy[0].setButton(4,False)
Thank you Jabberwock but unfortunately that didn't work and made the button stuck, I can't turn it off.Jabberwock wrote: ↑Wed Sep 02, 2020 5:39 am Try this:
Note that this makes the button press rather short (one frame), which might not be sufficient for all applications. You can solve it using timers or just make the toggle value higher and decrease it each frame until it is zero.Code: Select all
def update(): global toggle if (midi[0].data.buffer[0] == 4) and (midi[0].data.buffer[1] == 127): toggle = 1 if starting: midi[0].update += update toggle = 0 if (toggle == 1): vJoy[0].setButton(4,True) toggle == 0 else vJoy[0].setButton(4,False)