c0redumb / midi2vjoy

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

LPD8 Buttons stay pressed #4

Open kokoi1 opened 5 years ago

kokoi1 commented 5 years ago

First of all thank you very much for this amazing tool.

I mapped my LPD8, and while the knobs are working great as all the axis, the buttons are working ones but then stay stuck as pressed.

The tester give me these values when a button is being pressed: [[[144, 40, 11, 0], 2588]] [[[128, 40, 127, 0], 2813]]

I tried to map button 1 as 144 40, but it seems that then the joystick doesn't know that the button is not being pressed anymore (I guess event 128 40).

I hope that I'm just doing something wrong here.

Daniel

jphustman commented 4 years ago

This is happening to me too. Do you know how to unpress buttons? I'll dig into the code but it might take awhile to figure out!

litaniast commented 4 years ago

Same issue on the Rock Band Keyboard. (the keyboard controller for Rock Band 3, but connected via midi)

caseyAEC commented 4 years ago

Having the same issue with AKM320 keyboard. Mod wheels and Slider working fine, but keypresses stay on when pressed.

cpyarger commented 4 years ago

Same with my Xtouch compact

cpyarger commented 4 years ago

I just submitted a pull request that fixes this issue

lareooreal commented 3 years ago

I added a modified version in the issue section with a complete hacked script to adress this problem as a zip file This should work Lareooreal

tanskudaa commented 3 years ago

The problem is here:

elif key[0] == 128:
    # A button off input
    vjoy.SetBtn(reading, opt[0], int(opt[1]))

which sends the reading of the physical button pressed (eg. velocity on piano) for vJoy and vJoy uses this as the state of the virtual button. But my piano, and I'd guess many other MIDI devices as well, send a default reading of 64 (pushed with half pressure out of the maximum) for every button release message. If you change the code to send a 0 every time it receives a status 128 (note off on channel 1) it's fixed. You need to specify every note off in the .conf-file though:

midi2vjoy.py:
elif key[0] == 128:
    # A button off input
    vjoy.SetBtn(0, opt[0], int(opt[1]))

example.conf:
# Note on
144     24  1   1

# Note off
128     24  1   1

Thanks for the author of the program. I'm modifying it to use piano chords as gamepad buttons 🌚

fyyyyy commented 2 years ago

Also need to add 129 and 145 for i.e. Novation Circuit which sends these IDs for the second instrument

        elif key[0] == 128 or key[0] == 129:
                # ...
        elif key[0] == 144 or key[0] == 145: