Execute outgoing action (timer and/or delay) rule if there's no incoming midi for x seconds

Regalix

2020-02-10 03:00:14

Hello,

I've created a very good project for mouse take over and it works perfectly fine.

However, I need to end the translator chain with an automatic mouse-up action ONLY if the following conditions are met:

1. No incoming midi event has been detected for 5 seconds.

2. I didn't execute mouse-up action manually by clicking on a dedicated button on a midi device (with an appropriate translator set).

But here's the quirk: The timer, or delay, shall always restart after every incoming midi event.

So, if after 3 seconds of no incoming midi there's an incoming midi data again - the timer shall restart and start count from zero to 5.

I would appreciate any help at this phase for this.

Thank you in advance!

Steve-Bome Forum Moderator

2020-02-10 04:11:21

Hi,

What you are describing is a watchdog timer.

On the last action in your timer chain. Set a global variable (eg ga) to a value of 1 and then start the 5 second timer.

Set actions for the following MIDI raw events (this will cover most MIDI messages but not System Exlusive

Name: Any 3 byte message

Incoming: Raw MIDI oo pp qq

Rules:

// This will handle notes, CC messages, pitch bend 

ga=0

Name: Any two byte message

Incoming: Raw MIDI pp qq

Rules

// This will handle Program Change messages

ga=0

Name: Any one byte message

Incoming: Raw qq

rules

// This will handle MIDI clock, and a few others

ga=0

 

Then when the timer trigger

Incoming : Timer "watchdg"

Rules:

if ga==0 then exit rules, skip outgoing action

Outgoing action  "Left mouse up"

Also you need to set up a translator for your button that does left mouse up. Just make sure that it sets ga=0 so that the watchdog timer does not yet trigger the action.

If you have any SysEx messages that you want to prevent the action, you need to count the bytes and add them based on the exact count of bytes such ase

Incoming: Raw MIDI F0 oo oo oo oo oo oo oo oo oo F7

Rules

// Any 11 byte Sysex message

ga=0

 

If you use things like MMC or MSC you might want to add a few more translators for those cases as well.

 

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

Regalix

2020-02-10 19:54:58

Hello,

Thanks a lot for a super-fast response! Really impressive.

OK, everything works, except for the automatic click release after x seconds. I\'ve set everything you\'ve suggested. Please find attached the project, I guess translator 8 and 9 are the critical ones.

Thank you in advance!

Best regards.

Steve-Bome Forum Moderator

2020-02-10 21:20:25

comment

I don't see any translators that start a timer? Did you post the right version of the project file?

Regalix

2020-02-10 21:41:55

comment

Hello, Thanks a lot for a super-fast response! Really impressive. OK, everything works, except for the automatic click release after x seconds. I've set everything you've suggested. Please find attached the project, I guess translator 8 and 9 are the critical ones. Thank you in advance! Best regards. PS. Please find the attached project in my previous answer.

Steve-Bome Forum Moderator

2020-02-10 22:11:38

comment

The project file you posted doesn't seem to have any translators I described to include.

Regalix

2020-02-10 22:38:41

comment

Are you sure? Check the translator number '9' - 'Mouse up / release automatic set delay'. Maybe we misunderstand each other?

Steve-Bome Forum Moderator

2020-02-10 22:53:56

comment

There are no translators as I described to start the timer. There are no translators as I described with a timer as a trigger.

Regalix

2020-02-11 00:42:47

V2.


Attachments:

Mouse take-over Win 10 v2.bmtp

Regalix

2020-02-11 00:42:59

comment

My bad, sorry! Check v2 please.

Steve-Bome Forum Moderator

2020-02-11 02:55:48

Hi,

Try the attached

I added 3 translators for 1, 2 and 3 byte MIDI messages. They will all trigger the watchdog timer if the mouse is down "ga=1"

Any time we click down on the mouse we set the global variable ga to 1 in the rules

The timer looks to see if the mouse is down and if it is, sends a click up if ga is not a 0.

I use the global variable gb to determine the timer length (in ms)

Have fun

 

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

 

 


Attachments:

Mouse-take-over-Win-sjc-10-v2.bmtp

Regalix

2020-02-11 04:33:26

comment

Fantastic :) Work as a charm. Thank you very much. I need to do some refinements. 1. In the log window, I've noticed that the 'Left mouse button down' command is executed (re-entered) with every movement of the 'Mouse Movement' translator. Is it possible to just fire it up at the beginning of the (5 sec) session? 2. Can the session end if any movement of the physical mouse is detected, as well? (And/Or) 3. Also, shall translator 'Steve's Test' remain or can I delete it? Thank you for your wonderful support.

Steve-Bome Forum Moderator

2020-02-11 04:43:01

1) Is it possible to just fire it up at the beginning of the (5 sec) session?

Answer 1)

If you put this rule in your mouse down button translators at the beginning, they will not trigger a mouse down a second time.

if ga==1 then exit rules, skip outgoing action

2) Can the session end if any movement of the physical mouse is detected, as well?

Answer 2)

No, MT Pro does not detect mouse physical movement outside of what it initiates.

3)Also, shall translator 'Steve's Test' remain or can I delete it?

Answer 3)

You can delete it or disable it. I usually disable them rather than delete them until all my testing is complete. It is much easier to just check the translator if I need it again other than re-create it.

 

You are welcome! I'm glad you find this useful.

 

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

 

Regalix

2020-02-11 06:13:10

comment

110% quality code :) Thank you again, I'm very satisfied! Just to be sure about one thing. This project is only depending on the dedicated midi data transmitted through a dedicated midi channel from a dedicated midi controller for this 'mouse take over' task. Therefore, we do not need to set a timer watchdog filter to depend on broad data. Just from the input data already defined in this project. In your post from February 10, 2020 4:11 am, there's a lot of data mentioned. maybe you've already removed those rules. If not, please let me know where I shall change that as I can't find that in the 'Timer' translator. Thank you in advance.

Steve-Bome Forum Moderator

2020-02-11 06:19:41

comment

If you don't want broader incoming MIDI messages like all 3 note, all 2 note and all 1 note, then set up translators for the existing incoming messages to just trigger the timer and disable the 3 broader messages I had set up. You basically duplicate your existing translators with a new outgoing action of the timer. Anything that clicks down on mouse you need to set ga=1. Other than that, I don't thing you need any rules. Just execute the timer. Steve

Regalix

2020-02-12 01:37:28

comment

I have an idea for the 'upgrade' of this project. Actually, it is a necessity as it turned out that not all destinations I'll control with this project transcribe the input values in the same manner. Therefore I need to set up a 3 'switches' which will increase the outgoing values with 50%, x 2 or x 4 pixels of the original value. ::: Example 1 / Default, current settings Every appropriate midi message triggers an outgoing mouse movement with 4 pixels. ::: Example 2 / 50% increase; Every appropriate midi message triggers an outgoing mouse movement with 6 pixels. ::: Example 3 / x 2 increase; Every appropriate midi message triggers an outgoing mouse movement with 8 pixels. ::: Example 3 / x 4 increase; Every appropriate midi message triggers an outgoing mouse movement with 16 pixels. Switching should stay selected for the whole session until I select another (or reset button which will always set output values to the default set value). Please let me know what do you think is the best approach to add this. I hope it is not too complicated? Thank you for your support!

Steve-Bome Forum Moderator

2020-02-12 01:57:56

comment

Seems a bit like an over complication to me, but I think you now have an idea on how watchdog timers work so you should be able to do it. Just make sure each incoming message restarts the timer so it doesn't do a mouse up until you are done with your incoming MIDI messages. Steve

Regalix

2020-02-12 03:56:27

comment

Yes, that part with a watchdog is done, too, everything works flawlessly. Thank you again.

Steve-Bome Forum Moderator

2020-02-12 04:29:03

comment

Glad to have been of help!