Use a relative Encoder as a click and Drag Mouse Action on a Mac with MTP

Encoder-Mouse-Drag-Example Steinberg Ai.bmtp (733 Bytes)

Hi, I’m trying to use a relative encoder on my controller to turn knobs on software like Reaktor on my Mac. The idea is to point the mouse to the knob and then use the encoder to click and drag the knob. In Reaktor the knob is turned with a vertical movement of the mouse.
The closest I could get, modifying a project I found here, kind of work, but is not really efficient, because when I’ve finished turning the knob the mouse pointer usually remains “attached” to the knob, so when I move to mouse away the parameter will continue to change.
Also if i need to turn up the knob a lot I’ve noticed that the mouse pointer will move up way more than when i do it with a real mouse drag, and it will stop working before the knob has reached maximum value.
Please note that I want to move knobs that do not accept the mouse wheel as an input, hence the need to click and drag with the mouse button pressed (I already tried to transform the encoder in the mouse wheel with MTP and it works quite well)
Regarding the MIDI side of things, my encoder is transmitting CC60 with a value of 1 when turned up and a value of 65 when turned down
Also I can press the encoder and it generates a Note On 58 with a velocity of 127 when pressed and a velocity of 0 when released.
I’m attaching here the project I created and thanks in advance for any reply

Hi,
Try the attached example. In this case a press is not required.
The click and drag operation will occur at whatever the current mouse location is. I set a timeout of 250ms so that when you are done, it should not get stuck in drag mode.

mouse-click-and-drag-relative-vpot.bmtp (4.0 KB)

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz
1 Like

Hi Steve and thanks for the quick reply.
The mouse is no more stuck in drag mode, but, aside the fact that the knob response is reversed (it goes up when i turn anti-clockwise and down when I turn clockwise) the biggest problem is the same I had before, the mouse soon goes “out of range” in the sense that it moves too far away from the knob and the knob stops moving.
The only way to make it work is to move the knob just a bit and then reposition the mouse, so it’s not very efficient

1)In the rules of translator 0.1 (Preset 0, translator 1), after
// Multiplier
rr=rr*3

  • Add
    rr=rr*-1

This will reverse the mouse direction

You may also need to change the multiplier from 3 to 2 or remove the multiplier completely

  1. Translator 0.2 - Change to a longer delay. Maybe 500ms instead of 250 ms.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Thanks again, now I understand what the multiplier is doing, so if I remove it I get the finer resolution I can get with the mouse while with a value of 2 the steps are bigger and so on. There’s still the problem that if i stop moving the encoder the mouse is now away from the knob and I have to reposition it, if I want to continue to control the same knob, but I don’t know if there’s a solution for this. On the PC I use a Microsoft Surface Dial paired with a software called Elephant that can simulate the click and drag behavior with a so called trackball mode, so the pointer will not move while the knob is being dragged, but probably a trackball mode can’t be implemented in MTP.

You would need to establish the starting position of the knob each time you turn it since as you say, the mouse will move to a new position. If your knob is always in the same place then you can set the mouse coordinates on the click down action. Otherwise, you somehow need to determine the position of the knob which MT Pro is not aware. For Windows, I have a program (MIDBuddy) that is a helper that converts mouse movements to MIDI and sends this information to MT Pro. That way MT Pro always knows the position of the mouse. Unfortunately this helper program works only on Windows. I use a special SysEX MIDI format so I can tell position on large screens with multiple bytes.

If there is something on the Mac that can send mouse position information, via MIDI, then you could wend MIDI to MT Pro to tell it where the mouse is and it would remember it’s last click position.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz
1 Like