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.
Button Events
Moderator: Moderators
Re: Button Events
Hi PaulGee,
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.Is there anyway to overcome this.
We're looking into 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.
Nuno Gomes
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
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
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);
}
}
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
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);
}
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);
}
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.
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.