No keyboard events in managed code

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

Moderator: Moderators

Post Reply
Weiman
Posts: 2
Joined: Thu May 10, 2007 12:31 am
Location: Sweden

No keyboard events in managed code

Post by Weiman »

I'm trying to use the COM API from C#. The SensorInput event works fine, but I never receive the KeyDown event. The code looks like this:

Code: Select all

TDxInput.Device device = new TDxInput.Device();
device.DeviceChange += new TDxInput._ISimpleDeviceEvents_DeviceChangeEventHandler(device_DeviceChange);
TDxInput.Sensor sensor = device.Sensor;
if (sensor != null)
{
	sensor.SensorInput += new TDxInput._ISensorEvents_SensorInputEventHandler(sensor_SensorInput);
}
TDxInput.Keyboard keyboard = device.Keyboard;
if (keyboard != null)
{
	keyboard.KeyDown += new _IKeyboardEvents_KeyDownEventHandler(keyboard_KeyDown);
}
device.Connect();
I'm using a SpaceNavigator with latest drivers on WinXP. All samples work like a charm.
regards,
Johannes
ABB Robotics
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi Weiman,

Not entirely sure here but perhaps the line:

Code: Select all

keyboard.KeyDown += new _IKeyboardEvents_KeyDownEventHandler(keyboard_KeyDown);
should be replaced by:

Code: Select all

keyboard.KeyDown += new TDxInput._IKeyboardEvents_KeyDownEventHandler(keyboard_KeyDown);
Nuno Gomes
Weiman
Posts: 2
Joined: Thu May 10, 2007 12:31 am
Location: Sweden

Post by Weiman »

Thanks for pointing that out, I'm surprised it even compiled before. Unfortunately it didn't help, still no keyboard events :(
regards,
Johannes
ABB Robotics
mbonk
Moderator
Moderator
Posts: 181
Joined: Mon Dec 04, 2006 4:06 am

Post by mbonk »

Hi Weiman,

The code looks ok. I am assuming that keyboard_KeyDown is defined something like the following.

Code: Select all

        void keyboard_KeyDown(int keyCode)
        {
            if (keyCode == 31)
            {
                // Fit View
            }
        }

I think what may be the issue is the button configuration setting in the 3Dconnexion Control Panel.

To check what is being used start up your application and with it still active and in focus either double click the 3dx icon in the systray or press the right button on the SpaceNavigator. This will open the 3Dconnexion Control Panel.
Please note the control panel is process sensitive. The button assignments for the device are listed in the 'Button Configuration' tab. Changing the assignment for 'L' to button 1 will cause a keydown event for button 1 when the L button is pressed.


Markus
Post Reply