Button Events

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

Moderator: Moderators

Post Reply
PaulGee
Posts: 6
Joined: Mon Apr 23, 2007 7:17 am

Button Events

Post by PaulGee »

I have an application in C# which is detecting the key presses on a space navigator. However with the Any Application configuration I can detect the left key but in the standard configuration the right button always displays the control panel.

Is there anyway to overcome this. Also if I call the GetKeyLabel call in the any application configuration, I get a COM exception otherwise it works fine with a custom config.

Any thoughts?

Many thanks

Paul.
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Button Events

Post by ngomes »

Hi PaulGee,
Is there anyway to overcome this.
Open the 3Dconnexion Control Panel and assign the right key to the desired command. As you pointed out, this will create a custom configuration file.
Also if I call the GetKeyLabel call in the any application configuration, I get a COM exception otherwise it works fine with a custom config.
We're looking into this.
Nuno Gomes
mbonk
Moderator
Moderator
Posts: 181
Joined: Mon Dec 04, 2006 4:06 am

Post by mbonk »

Hi,

Currently we cannot reproduce any problems with GetKeyLabel(): the method passes all our acceptance tests.

A COMException is generated when the COM component returns a HRESULT to the RCW which indicates some sort of error has occured: for example trying to get the button 2 KeyLabel when button 2 does't exist.

The COMException occurs due to following code

Code: Select all

      void device_DeviceChange(int reserved)

      {

         int key;

         string strKeyLabel;

         for (key = 1; key <= 3; key++)

         {

            strKeyLabel = this.keyboard.GetKeyLabel(key);

            Console.WriteLine("KeyLabel is {0}.", strKeyLabel);

         }

      }
when trying to get the label of key 3 for a SpaceNavigator which has no key 3.

With no device attached the above code will throw the exception trying to get key #1 (a non-device has no keys).

BTW the KeyLabel is the label of a key as it is printed on the device (or if nothing is printed on the device, then that what would be printed on the device i.e. in the case for a SpaceNavigator
PaulGee
Posts: 6
Joined: Mon Apr 23, 2007 7:17 am

Post by PaulGee »

Here is a code snippet. Basically I register an event handler for the key down event.

Under the AnyApplication config when I press the left button the key down event is called and the keyCode value is 31. I then try to get the label for the code and this causes the COM exception. The right button is not detected at all and opens the control panel.

Hope that helps a bit.

Paul.
......
spaceButtons.KeyDown += new TDxInput._IKeyboardEvents_KeyDownEventHandler(spaceButtons_KeyDown);
........
void spaceButtons_KeyDown(int keyCode)
{
string key;

key=spaceButtons.GetKeyLabel(keyCode);
}
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi PaulGee,
Under the AnyApplication config when I press the left button the key down event is called and the keyCode value is 31.
If you check the Control Panel, what command is assigned to the "left" button?
PaulGee
Posts: 6
Joined: Mon Apr 23, 2007 7:17 am

Post by PaulGee »

Left is assigned Fit
Right is assigned 3DxWare Panel.
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi PaulGee,

Functions "Panel" and "Fit" are to be implemented in the application and do not correspond to real buttons. This will be clear in a documentation update we are preparing . The functions are sent as virtual button events with keyCode 30 and 31, respectively.

The fix for your code is to ensure that you only call GetKeyLabel() with keyCode below or equal to Keyboard::Keys(). See mbonk's post above.
Post Reply