Keystrokes to MIDI (3Dconnexion SpaceMouse)

Pablo

2016-03-03 09:49:13

Hi,

Yesterday I bought my Bome Midi Translator Pro license but after reading the manual and make some translation tests, I couldn´t make it work as expected yet.

I´m on Mac OS X El Capitan, trying to configure a 3Dconnexion SpaceMouse® Wireless as a MIDI controller.

The SpaceMouse comes with a settings panel which allows you to assign keystrokes to each axis/button with any of these parameters:
  • - Press and Hold (hold)
    - Press and Release (toggle)
    - 1 time/sec, 2 times,/sec, ..., 50 times/sec
    - Every 2 secs, 3 secs, ..., 10 secs
Also it allows you to assign direct keystrokes (Q, A, 1, etc.) or keystrokes + modifiers (Cmd + Q, Option + Shift + A, etc.)

Do you know what´s the right way to create Presets, for example to configure a MIDI -64 +64 knob and a 0-127 MIDI knob, from incoming pairs of keystrokes (i.e. "Cmd+Q" = "knob center > left", "Shift+Q" = "knob center > right")?

Thank you in advance.

florian

2016-03-04 11:38:06

Hi Pablo,

thank you for purchasing MT Pro. We've successfully used emulated keystrokes to trigger MT's incoming keystroke action, but you should definitely try!

The general approach for you is this:
  1. On OS X, make sure to allow MT Pro access to keystroke input:
    Select it in OS X System Preferences: Security & Privacy -> Privacy -> Accessibility
  2. Create a translator entry with

    Code: Select all

    Incoming: Keystroke
    Outgoing: MIDI
  3. Test
    In MT, enable the Log Window (from the View menu).
    Then switch to a different program. MT's incoming keystroke action is only active when MT is not the focused program. That's a safety measure so that you don't accidentally trigger all kinds of messages when just editing in MT.
    Now pressing the key should trigger the MIDI message. You should see it in the Log Window.
Let us know how it works. Please also test with the computer keyboard to make sure your general translation is correct.
Regards,
Florian

Pablo

2016-03-04 12:12:17

Thank you Florian,

One question left is:

"Do you know what´s the right way to create Presets, for example to configure a MIDI -64 +64 knob and a 0-127 MIDI knob, from incoming pairs of keystrokes (i.e. "Cmd+Q" = "knob center > left", "Shift+Q" = "knob center > right")?"

Regarding the use of modifier keys, I´ve already found this post:

http://www.bome.com/forums/viewtopic.ph ... oke#p22376

But I´m not sure what are the variables and rules I need to use to configure the behavior of 2 keystrokes for turning a knob L and R respectively.

Can it be done? In that case, how?


Regards.

florian

2016-03-04 13:04:15

yes, it works by using a global variable, say "ga" to remember the current value. Assuming that you use the translations for modifiers setting variables ms, mc, and ma (for shift, control, and alt), and an additional variable md for Command key, use these rules:

Code: Select all

Translator 1: Cmd-Q: left, Shift-Q: right
Incoming: Keystroke Q
Rules:
  if ms!=0 then ga=ga+1
  if mc!=0 then exit rules, skip Outgoing Action
  if ma!=0 then exit rules, skip Outgoing Action
  if md!=0 then ga=ga-1
  if ga>127 then ga=127
  if ga<0 then ga=0
Outgoing: MIDI B0 01 ga
In the example, it outputs controller #01 with the value derived from the keyboard. The last 2 "if" statements make sure that the controller value cannot exceed the MIDI range, which is from 0 to 127.

Pablo

2016-03-06 15:34:04

Hi Florian,

It works quite well, except 2 issues:

1. The speed of the movement from the SpaceMouse is too high. Even tough the SpaceMouse can increase/decrease the speed manually while using it as it has a kind of velocity sensitivity, at a minimum touch the speed is too fast. Could it be configured somehow from BMT, like using the Delay section? I have tried it entering 500MS there but it takes no effect.

2. If some axis is active i.e. Shift+X (+X rotation), and I want to combine it with another axis rotation simoultaneously, if the second axis has a Shift too,(the same modifier than the first one), i.e. Shift+Y (+Y rotation) both can rotate together at the same time. But if the second rotation keystroke has a Ctrl while the first one is holding with Shift, it stops the Shift, and viceversa. In that case it doesn´t combine both rotations at the same time, only the last one runs and the first one stops. Could it be fixed somehow?


Thank you.

florian

2016-03-07 20:56:30

Hi,
good to hear that it works in principle!

1) slowing down
This issue can be solved with a trick. Instead of increasing/decreasing ga by one, you could, e.g., only change it in steps of 1/3. But ga can only be an integral number! So what can be done is to allow higher values for ga and scale it by 3 before outputting the control change (using a local variable pp):

Code: Select all

Translator 1: Cmd-Q: left, Shift-Q: right
Incoming: Keystroke Q
Rules:
  if ms!=0 then ga=ga+1
  if mc!=0 then exit rules, skip Outgoing Action
  if ma!=0 then exit rules, skip Outgoing Action
  if md!=0 then ga=ga-1
  if ga>381 then ga=381
  if ga<0 then ga=0
  pp=ga/3
Outgoing: MIDI B0 01 pp
Note how the maximum value of ga is also increased to 381 (=3 times 127).

2) Shift Up when Ctrl down
It seems that the device sends SHIFT UP before starting CTRL DOWN (you can verify that with the Log Window). I don't think we can do anything about it in MT, because in other scenarios, that will be perfectly valid and we don't have a way to tell when the SHIFT UP is legitimate or not.
But you possibly you can change it in the 3D Connexion settings by e.g. using CTRL for all movement, and not using SHIFT at all, and using different keys to distinguish up from down, etc. If you can freely assign the keys? Of course, then you'll need to add another translator so that you handle up and down individually.

let us know!

Thanks,
Florian

Pablo

2016-03-07 23:37:41

Hi Florian,

Again, your solution #1 works like a charm ;)

Regarding the #2 issue, as you said maybe the 3DSpaceMouse is sending the first modifier (shift) up when starting the other modifier (ctrl).

There are 4 modes which the axis can be configured in the device mapping it with keystrokes:

- Press and Hold (hold)
- Press and Release (toggle)
- 1 Time/Sec, 2 Times/Sec, etc.
- Every 2 Secs, Every 3 Secs, etc.

I don´t know why but the Press and Release (toggle) mode is the only one that works with no issues. The hold mode acts like a crazy knob, jumping to random and unexpected values. I´ll try to fix it regarding your instructions and I´ll let you know.

One last thing: Is it normal that writhing this post in Safari the Bome´s Keystroke In indicator turns on all the time? If I type X, Y or Z, the MIDI Out is turned on too.

PS: Sometimes when I focus on another window than Modul8 while moving the 3DSpaceMouse, the values don´t stop anymore and I need to force Bome to shut down. If you know any solution to prevent this behavior, please let me know.

Thank you.

florian

2016-03-08 01:16:30

it's normal that the Keystroke In indicator lights up when pressing keys on the computer keyboard because you're using Keystroke Incoming actions. And if you have a translator from SHIFT-X to MIDI, then it will send that MIDI message when pressed on the computer keyboard...

But it's not normal that MT Pro stops functioning! This is the first time someone reports a freeze (or what exactly is the symptom?), so any further information about this are welcome!

Best,
Florian

Pablo

2016-03-08 01:48:21

Hi,

It´s the opposite of a freeze. For example, if I turn a 3DSpaceMouse axis that sends shift+y repeatedly I leave the focus of Modul8, and then I stop moving the 3DSpaceMouse, the shift+y doesn´t stop anymore and it blocks the scroll in Safari, writes "y, y, y,..." on the text fields, etc. It has happened rarely actually and maybe it´s related with the 3DSpaceMouse.

Pablo

2016-03-08 11:50:23

Hi again Florian,

Regarding the #2 issue, I now understand what´s happening so I´ll try to explain it a little better:

1. When holding down Shift+Y and then Shift+Z keystrokes at the same time, both movements are correct as they´re expected.
2. When holding down Shift+Y and then Ctrl+Z at the same time, suddenly the Shift+Y turns into Ctrl+Y.

Is there a rule to avoid Ctrl overrides Shift and vice-versa while holding several keystrokes, without using different modifiers (Option, Cmd, etc.) for each keystroke?


Thank you.

florian

2016-03-08 12:23:39

Hi,
of course! If SHIFT and CTRL are down, the rules will negate each other:

Code: Select all

if ms!=0 then ga=ga+1 // SHIFT DOWN
if mc!=0 then ga=ga-1 // CTRL DOWN
so you need a rule what to do if SHIFT and CTRL are down. Problem is, you need to settle on one, because they contradict each other. In any case, the rules will get a little more complicated.

A relatively simple way is to add up ms and mc to a temporary variable and then see if the value is 2:

Code: Select all

if ms!=0 then ga=ga+1 // SHIFT DOWN
if mc!=0 then ga=ga-1 // CTRL DOWN
qq=ms+mc
if qq==2 then ga=ga+1 // CTRL+SHIFT DOWN
Thanks,
Florian

Pablo

2016-03-08 12:50:58

Hi Florian,

That solution doesn´t work here, maybe there are more changes in the code needed.

I´ve found an alternative way using 3 modifiers (Shift=ms, Ctrl=mc and Option=mo):

X Rotation

Code: Select all

Translator 1: Shift+X: +turn, X: -turn
Incoming: Keystroke X
if ms==0 then ga=ga+1
if ms==1 then ga=ga-1
if ga>381 then ga=0
if ga<0 then ga=381
pp=ga/3
Outgoing MIDI: B0 01 pp

Y Rotation

Code: Select all

Translator 2: Ctrl+Y: +turn, Y: -turn
Incoming: Keystroke Y
if mc==0 then gb=gb+1
if mc==1 then gb=gb-1
if gb>381 then gb=0
if gb<0 then gb=381
qq=gb/3
Outgoing MIDI: B0 02 qq

Z Rotation

Code: Select all

Translator 3: Option+Z: +turn, Z: -turn
Incoming: Keystroke Z
if mo==0 then gc=gc+1
if mo==1 then gc=gc-1
if gc>381 then gc=0
if gc<0 then gc=381
rr=gc/3
Outgoing MIDI: B0 03 rr

I´m not sure it´s the best solution, but it works well actually. If you find some issues in this code, please let me know.


Thank you.

Pablo

2016-03-08 13:54:46

Now the issue there is I cannot assign modifiers (Shift, Cmd, etc.) to another keystrokes and functions, as they override again the previous I´ve made...

Instead of using modifiers, is there any way to assign a pair of keystrokes (i.e. "q" and "w") to the same MIDI message?


Thank you.

florian

2016-03-08 14:11:00

of course, you can use any key separately. Then, use separate translators for increment and for decrement.