Profile name format with .NET

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Profile name format with .NET

Post by JFB »

Hello all,

Developing in C# for an application (.NET 4.7.2), I'm using the wrapper in the SDK 4 to connect the SpaceMouse.
To connect the device by using the method Open3DMouse(string), I have to enter a profile name.
Setting a name having letters with accent (like 'Pièce') raises the COM exception (in french):
"Indicateur proposé incorrect (Exception de HRESULT : 0x80040001 (OLE_E_ADVF))"
Is there some limitations on the name to purpose, as only ASCII format, or is there a mean to have letters with accent, and globally unicode text, because I would show name on the device in chinese and japanese format.

Thank you!
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

JFB wrote: Tue Jul 05, 2022 2:43 am Is there some limitations on the name to purpose, as only ASCII format,
The parameter passed to Navigation3D.Open3DMouse(string) is limited to an ASCII string, yes. This happens in the marshalling to native code.

I don't know why we have that limitation. We're looking into it.

Converting the string to a UTF-8 sequence of characters may work but I'm not sure you'd want to rely on that in production.
Nuno Gomes
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

We're tracking this with reference WIN-1081 and we have modified the marshalling to support the full Unicode character set in Navigation3D.Open3DMouse() in the assembly included in v. 10.8.8 of 3DxWare 10.
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Re: Profile name format with .NET

Post by JFB »

Hi,

Thank you for the fix on Open3DMouse, it works.
I have found another behavior on the title with ASCII format when I set a CommandSet with Unicode text.
Using the constructor of CommandSet with <name> and <label> parameters shows for the label <Pièce> the text <Pièce>, and for the text <Page d'accueil> the text <Page d&apos;accueil>.
I have tried to set a Utf8String with those names and set it to the Label property of the CommandSet, but I have the same behavior.
Is there another way to have the correct name on this CommandSet?
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

JFB wrote: Thu Oct 06, 2022 6:36 am I have found another behavior on the title with ASCII format when I set a CommandSet with Unicode text.
Using the constructor of CommandSet with <name> and <label> parameters shows for the label <Pièce> the text <Pièce>, and for the text <Page d'accueil> the text <Page d&apos;accueil>.
What exactly are the strings? Are you passing "<Pièce>" as a UTF-8 -encoded string?
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Re: Profile name format with .NET

Post by JFB »

< > are the delimiters just for here, the strings are "Pièces" and "Page d'accueil", I pass them as string type as well as Utf8String type without success.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

JFB wrote: Thu Oct 06, 2022 11:01 pm the strings are "Pièces" and "Page d'accueil", I pass them as string type as well as Utf8String type without success.
They need to be passed as UTF-8.

Can you send us a small demo project so that we can reproduce this ourselves?
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Re: Profile name format with .NET

Post by JFB »

Please find here the sample
TestSpaceMouseUTF8.zip
Sample
(79.73 KiB) Downloaded 294 times
, uncomment lines to test different ways.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

The issue you reported yesterday is unrelated to the original problem.

You are creating a CommandSet but you are not exporting it to the driver. In other words, you are not calling Navigation3D.AddCommandSet(). Also, the "name" parameter is a string identifier and is not displayed to the user unless something unexpected happens like your scenario: program calling Navigation3D.ActiveCommandSet() for an non-existing command set.

Refer to the MainExecutor.ExportApplicationCommands() method in the SDK 3DxTestNL sample at samples\3DxTestNL\Wpf3DTest\MainExecutor.cs.
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Re: Profile name format with .NET

Post by JFB »

Sorry I agree with you it is not related to the COM exception by setting Unicode text into the profile name, but as it relies to the same problem using Unicode into the title bar on the SpaceMouse, I was thinking it was the right place for this problem.

The sample I provided here is just to reproduice the problem, and it is always there even if a change the sample code like this:

Navigation3D spaceMouseDevice = new Navigation3D(this);
spaceMouseDevice.Open3DMouse("Test");

CommandTree cmdTree = new CommandTree();
string setName = "Page d'accueil"; // "Pièce";
CommandSet cmdSet = new CommandSet("Test", setName);

// Test with Utf8String, same problem.
//Utf8String utf8String = new Utf8String("Page d'accueil");
//cmdSet.Label = utf8String;

cmdTree.Add(cmdSet);

spaceMouseDevice.AddCommands(cmdTree);

spaceMouseDevice.ActiveCommandSet = setName;

The code I am using in production is even bigger than that because I fill commands with their images into the application tree, and the tree commands have no problem with Unicode texts.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

JFB wrote: Fri Oct 07, 2022 7:01 am spaceMouseDevice.ActiveCommandSet = setName;
You need to activate the command set by the name identifier, not the label.

Change the line quoted above to:

Code: Select all

spaceMouseDevice.ActiveCommandSet = "Test";
And it should work for you.

The "name" parameter is a unique string identifier (the node "id") and is expected to be ASCII. The "label" is the string that can be localised to any language. The Navigation3D assembly takes care of all required string encoding. You do not need to worry about UTF-8, Unicode or anything of the sort. Just use the built-in "string" type but keep identifiers as simple ASCII strings.
JFB
Posts: 6
Joined: Tue Jul 05, 2022 2:27 am

Re: Profile name format with .NET

Post by JFB »

Thanks, it works!

it's a pity that the key is of type uft8 in the constructor of the base class CommandTreeNode, it doesn't help to understand it wants ASCII string.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Profile name format with .NET

Post by ngomes »

JFB wrote: Sun Oct 09, 2022 11:10 pm it doesn't help to understand it wants ASCII string.
We need to look into this, yes.
Post Reply