Creating macro functions...

Discussion on the upcoming major revision of 3Dconnexion 3DxWare

Moderator: Moderators

Creating macro functions...

Postby mikycoud » Wed Apr 18, 2012 3:11 am

Hi,
I just acquired a Space navigator which I'm using under W7 X64, with the latest beta drivers.
I 'm currently struggling trying to create a custom macro function to assign to either button.

-Is there a tutorial, or any kind of help files available to explain this aspect of your driver configuration?

-If not, how would you go about defining a function to emulate, say, Photoshop zooming in function which is normally a Alt+Space+Mouse Left or Mouse right?

Any help is appreciated as I've been spending the whole morning trying to wrap my head around this to no avail...

BTW, why do I not see simple keyboard keystrokes assignement options in the button customization options? (weird, as I can assign a keystroke to a Tilt, Pan, etc, but not to a button)

Thanx!
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Re: Creating macro functions...

Postby jwick » Wed Apr 18, 2012 5:37 am

mikycoud wrote:-If not, how would you go about defining a function to emulate, say, Photoshop zooming in function which is normally a Alt+Space+Mouse Left or Mouse right?
We don't currently have a way of assigning a key (e.g. space key) and a mouse key at the same time. If you are capable of writing simple code in C, we can tell you how to do this. The driver has a very simple extension mechanism in which you can do anything you desire.

mikycoud wrote:BTW, why do I not see simple keyboard keystrokes assignement options in the button customization options? (weird, as I can assign a keystroke to a Tilt, Pan, etc, but not to a button)
This is normally under a "Manage Macros..." button in the Buttons tab, after you select the "Macros" type of Function. Macros may be missing from the profile you are editing. If so, let me know.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Re: Creating macro functions...

Postby mikycoud » Wed Apr 18, 2012 7:18 am

jwick wrote:We don't currently have a way of assigning a key (e.g. space key) and a mouse key at the same time. If you are capable of writing simple code in C, we can tell you how to do this. The driver has a very simple extension mechanism in which you can do anything you desire.


Yep, I'd like to know please...
(However, is there no way to just edit the xml file instead, and insert some custom code there?)

mikycoud wrote:BTW, why do I not see simple keyboard keystrokes assignement options in the button customization options? (weird, as I can assign a keystroke to a Tilt, Pan, etc, but not to a button)
This is normally under a "Manage Macros..." button in the Buttons tab, after you select the "Macros" type of Function. Macros may be missing from the profile you are editing. If so, let me know.[/quote]

Right, so if I understand you correctly, assigning a simple keystroke (say the letter 'V' to one of the buttons require creating a Macro, right?

This actually creates another problem for me:
if I wanna assign alt+space to one of the keys, the macro records 'alt, space, -space, -alt' (or something like that, from memory), because it sees both the 'press' and the 'release' actions. SO when I actually use this macro in Photoshop, well nothing happens... (which is to be expected, since the macro sequence effectively cancels itself)

On the contrary, if I create a macro by just pressing alt+space, keep those keys pressed and then save the macro before releasing them (effectively just recording alt+space in the macro), then using that in Photoshop works, but then Photoshop considers that alt and space are always activated, since your driver never released those keys.

So how do I create and assign to a button a macro with alt+space that allows my softwares to understand that alt+space are activated when the button is kept pressed on, and deactivated when the button is released?

Thanx for your help!
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Re: Creating macro functions...

Postby jwick » Wed Apr 18, 2012 7:53 am

mikycoud wrote:
jwick wrote:We don't currently have a way of assigning a key (e.g. space key) and a mouse key at the same time. If you are capable of writing simple code in C, we can tell you how to do this. The driver has a very simple extension mechanism in which you can do anything you desire.


Yep, I'd like to know please...
(However, is there no way to just edit the xml file instead, and insert some custom code there?)
Like VBS? No unfortunately not. Are you a C/C++ programmer? I can email you a sample project (make sure your registered email address is correct). The extension mechanism works by allowing you to define a function in a DLL or an Exe, .bat, .vbs or whatever each time an event occurs. You can write this DLL function/script/... yourself. Take a look at the sample ZBrush4 profile. You will see that for each axis, the action is a function pulled out of a DLL that we ship. You can build your own DLL. In that DLL, you can use SendInput to send keystrokes in any order you want. DLL functions can be written for buttons and axes. You have to keep track of releasing the keys, as you want below for the alt+space+mouse left/right.

When the extension is invoked, the target you define is passed the name of the button/axis, and the value (button: 0/1, or axis: -/+something).

Here are two sample functions:
Code: Select all
// This is an example of an exported function.
extern "C" __declspec(dllexport) void ShowAxis(WCHAR *args)
{
   FILE *fp;
   if (_wfopen_s(&fp, L"C:\\tmp\\3DxSample.txt", L"a") == 0)
   {
      fwprintf(fp, L"Axis Event: %s\n", args);
      fclose(fp);
   }
}

extern "C" __declspec(dllexport) void ShowButton(WCHAR *args)
{
   FILE *fp;
   if (_wfopen_s(&fp, L"c:\\tmp\\3DxSample.txt", L"a") == 0)
   {
      fwprintf(fp, L"Button Event: %s\n", args);
      fclose(fp);
   }
}


mikycoud wrote:Right, so if I understand you correctly, assigning a simple keystroke (say the letter 'V' to one of the buttons require creating a Macro, right?

This actually creates another problem for me:
if I wanna assign alt+space to one of the keys, the macro records 'alt, space, -space, -alt' (or something like that, from memory), because it sees both the 'press' and the 'release' actions. SO when I actually use this macro in Photoshop, well nothing happens... (which is to be expected, since the macro sequence effectively cancels itself)

On the contrary, if I create a macro by just pressing alt+space, keep those keys pressed and then save the macro before releasing them (effectively just recording alt+space in the macro), then using that in Photoshop works, but then Photoshop considers that alt and space are always activated, since your driver never released those keys.

So how do I create and assign to a button a macro with alt+space that allows my softwares to understand that alt+space are activated when the button is kept pressed on, and deactivated when the button is released?

Thanx for your help!
You can do that, but not in the GUI. You have to edit the macro itself. That doesn't work though for multiple buttons. You could create one macro for alt+space press and another for alt+space release, but you would have to use two buttons to invoke the two macros. That's not what you want. Better to write a single custom function using the extension mechanism to just press both (three?) keys on the press, then release all of them on the release.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby jwick » Wed Apr 18, 2012 8:00 am

Here is another topic on extensions.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Re: Creating macro functions...

Postby mikycoud » Thu Apr 19, 2012 2:22 am

jwick wrote:Like VBS? No unfortunately not. Are you a C/C++ programmer? I can email you a sample project (make sure your registered email address is correct). The extension mechanism works by allowing you to define a function in a DLL or an Exe, .bat, .vbs or whatever each time an event occurs. You can write this DLL function/script/... yourself. Take a look at the sample ZBrush4 profile. You will see that for each axis, the action is a function pulled out of a DLL that we ship. You can build your own DLL. In that DLL, you can use SendInput to send keystrokes in any order you want. DLL functions can be written for buttons and axes. You have to keep track of releasing the keys, as you want below for the alt+space+mouse left/right.


Well, that sounds wonderful, but unfortunately a little out of my league.
I'd probably end up spending far more time getting this right than I can afford. I'm just a Web developper after all, and HTML, PHP and Javascript is more my cup of tea...
I'd gladly pay someone to do some custom scripting for custom profiles though...
Or better, I'd be delighted if somehow you could find a way to add a GUI based mouse axis mapping to the 3DMouse various axis's and buttons.

jwick wrote:You can do that, but not in the GUI. You have to edit the macro itself. That doesn't work though for multiple buttons...


I found other posts from users trying to accomplish sort of a similar thing:

viewtopic.php?t=4798

where the user says:

Voidward wrote:...I recently made a macro for photoshop which is alt rightclick mouse left/right which uses photoshop's opengl based brush resizer...


So how did he accomplish that? By using the dll method you mentionned?

Also:

viewtopic.php?t=4837

where the user inquires:

Voidward wrote:Is there a way to change the xml file in areas like <keypress> / <keyrelease> towards <pressandhold>?

E.g. it would be beneficial to use the two sidebuttons of the navigator assigned to certain keys- e.g. "Shift".


to which you reply:

jwick wrote:There are predefined actions for Shift, Ctrl, Alt, most keys. The predefined ones all work as PressAndHold. That is, they are pressed when you press the device button, then released when you release the button. In the profile, these are tagged with Type="Keyboard", not "Macro". Macros are quickly pressed and released and obviously can contain any number of keys. Keyboard actions are pressed and held and can only be a single key.

You can't define them in the GUI. If they are not in the profile for your application, copy them from the base.xml into your profile's ButtonActions list. Everything you can do is in the base. When you create an application profile, you are picking and choosing items from the base.

There is nothing to prevent you from defining your own Keyboard actions. You need to follow the trail to connect up all the pieces. In particular, the keyboard (and macros) are actually defined in the language file (e.g. en-us_def.xml). References to those items are used in the profiles.


SO if I get this all right, these are my three options:

    *Edit my Photoshop profile incorporating bits from the base.xml, so I can assign keyboard actions to one of my buttons (option which is not currently listed in the Macro function drop down menu). This method ensures that I do get the 'press and hold' behavior I'm after, BUT also means I'm restricted to a single key and no mouse axis mapping is possible.

    *Use a GUI macro which can contain any number of keys, but exhibits a 'press and release' behavior. Also, no mouse axis mapping is possible by default.

    *Use a custom macro, which would allow me to achieve my goal, but involves some (fairly easy to some, probably time-consuming for others :-) ) custom coding of the xml and ddl files.


Right?


Also, last question (I promise!): The advanced and macro functions interface on 3DxConfig in MAC OSX seems a bit more powerful and flexible than it is in 3DxConfig on Windows, from what I can gather.
Would it be possible to achieve what I want on a Mac and then somehow import the custom application xml template on my PC? (only asking cos I assume the xml's used by your driver are not vastly different from one OS to the next.)

Thanx again for bearing with me on this! Much appreciated...
And please please please, consider adding more GUI based custom mapping options to the Space navigator Axis's and buttons.

Thanx.
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Postby jwick » Thu Apr 19, 2012 6:25 am

The XML files are vastly different and the drivers are vastly different on the Mac vs Windows vs Linux, etc. In fact, there isn't one line of code in common. They are completely different platforms. We try to maintain similar functionality, but some things are easy and some things are impossible on the different platforms.

I do intend to add more functionality in the first point release of 3DxWare 10. First we need to get the first release out.

Since this macro seems to be fairly important to Photoshop users, I may write a custom function for it. You can test it.

Please confirm that this is what you want:

1) On a device button press you want to press the alt key and the space key at the same time as the Left Mouse Button.
2) These keys and buttons will be held down as long as you hold the device button down.
3) When the button is released, you want to release those keys.
4) You also want a version of this with the Right Mouse Button.
5) And what do these do in Photoshop? IOW, what should I call these functions?
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby mikycoud » Thu Apr 19, 2012 2:34 pm

jwick wrote:The XML files are vastly different and the drivers are vastly different on the Mac vs Windows vs Linux, etc. In fact, there isn't one line of code in common. They are completely different platforms. We try to maintain similar functionality, but some things are easy and some things are impossible on the different platforms.

I do intend to add more functionality in the first point release of 3DxWare 10. First we need to get the first release out.

Since this macro seems to be fairly important to Photoshop users, I may write a custom function for it. You can test it.


Wow, never expected the actual xml file to be THAT different. I guess it's a lot of work trying to maintain some kind of unity between platforms...
Hat off to you guys...

jwick wrote:Please confirm that this is what you want:

1) On a device button press you want to press the alt key and the space key at the same time as the Left Mouse Button.
2) These keys and buttons will be held down as long as you hold the device button down.
3) When the button is released, you want to release those keys.
4) You also want a version of this with the Right Mouse Button.
5) And what do these do in Photoshop? IOW, what should I call these functions?


Well, the whole idea behind my request (and, I think, the other ones I've seen in your forum) is to be able to assign to the 3D mouse axis's or buttons some photoshop events that rely on a combination of multiple modifiers and mouse clicks and mouvements.

A perfect exemple, and I think the most important to Photoshop users, would be the OpenGl based zooming function, which requires the user to press on alt+spacebar+mouse left click and, whilst keeping this pressed down, move your mouse up/right (to zoom in) or down/left (to zoom out). This OpenGl zooming is way smoother than say, CTRL+ or CTRL+scrollwheel.

The more I think about this, the more I'm convinced that the ideal way to implement it in a template would be in fact to create a macro and be able to map it to one of the device's axis's (rather than a button).
For instance tilting up would be a shortcut for alt+space+mouse left click+mouse mouvement up (zooming in). Tilting down would be the equivalent of alt+space+mouse left click+mouse mouvement down (zooming out). These keys and buttons would be held down as long as device is pushed in either its tilt axis and released when returning in its neutral position.

This would be a fantastic and intuitive use of the Space Navigator in Photoshop.
Oh, btw, the function couls be called OpenGL zooming, since, after all, it's exactly what it is...

Hope my explanation is clear enough...
Thanx...
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Postby mikycoud » Sat May 26, 2012 12:40 am

Hi,
Any update on this?

Thanx
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Postby jwick » Tue May 29, 2012 12:54 am

No enhancements are being worked on until after the next beta gets out.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Re: Creating macro functions...

Postby mikycoud » Wed Sep 05, 2012 1:05 am

Hi, just wondering if any of the recent betas add some functionality that would help me create specific macro functions (see original question)?
mikycoud
 
Posts: 9
Joined: Wed Apr 18, 2012 2:57 am

Re: Creating macro functions...

Postby jwick » Wed Sep 05, 2012 5:31 am

mikycoud wrote:Hi, just wondering if any of the recent betas add some functionality that would help me create specific macro functions (see original question)?
Nothing new. We are working on stability, not features for the first release. As mentioned above, you can do all you want with some C code.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Re: Creating macro functions...

Postby wiger123 » Wed Oct 03, 2012 10:54 pm

We don't currently have a way of assigning a key (e.g. space key) and a mouse key simultaneously. In case you can writing simple code in C, they can tell you how to do this. The driver has a simple extension mechanism in which you can do anything you desire.
wiger
wiger123
 
Posts: 1
Joined: Wed Oct 03, 2012 10:43 pm


Return to 3DxWare 10 Beta Forum

Who is online

Users browsing this forum: No registered users and 0 guests