Toggle a keystroke down/up with the same incoming signal?

Digital Sensei

2020-09-06 00:58:02

I use a product called aerodrums that outputs midi signals to play games. Think of it like an electric drum kit basically. I need to be able to strike one drum to press a key down and hold it until i strike the same drum again.
All I can think of for now is to use a very long timer on the key up delay and have a seperate drum to be a global Key up command. But that will be a hassle. Any insight?

Digital Sensei

2020-09-06 01:34:09

comment

I had the idea of maybe creating some sort of feedback loop to hold down the same note that i'm using to input. so like when I strike CH10 note 38 (the one i intend to use) it would output ch10 note 38 indefinitely, then have a second translator to turn that note held down into a keypress being held down. But I'm still not sure how i'd program the same note to also trigger a note off the next time i pressed it without the repeated "note on" canceling itself out by triggering the note off.

Steve-Bome Forum Moderator

2020-09-06 02:42:21

comment

So you want it to on first hit, send keystroke down and on second hit send keystroke up and so on?

Digital Sensei

2020-09-06 03:00:19

comment

Exactly!

Steve-Bome Forum Moderator

2020-09-06 03:32:35

Hi Something like this will work.

I use a global variable ga to track the key state. I toggle it so that it moves from 0 to 1 and 1 to 0 on every key press.

The first translator only fires if ga=1 and presses the "a" key down. The first tranlator also performs the toggle

ga=ga^1

 

The second translator fires only if ga==0 and sends keystroke "a" up.

 

I hope this helps!

 


Attachments:

Toggle-Key-Example-2020-09-05.bmtp

Digital Sensei

2020-09-06 03:56:30

comment

That worked perfectly! I just had to set gg as the variable on the second input i needed to also act that way. Thanks a lot! I had a feeling i was overthinking it a bit.

Steve-Bome Forum Moderator

2020-09-06 06:31:06

comment

Glad to have been of help!