Hello,
Can anybody help me with this.
I'm writing a program in c# 2005 and cannot get the code to see any keypresses from the SpaceNavigator. I know the code is connecting to the device as it reads in the correct device type and displays it, but it isn't seeing any key presses etc.
Heres the code;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace OE14_502_GUI
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
void keyboard_KeyDown(int keyCode)
{
keystate.Text = keyCode.ToString();
}
private TDxInput.Device device;
private TDxInput.Sensor sensor;
private TDxInput.Keyboard keyboard;
private void btController_Click(object sender, EventArgs e)
{
try
{
if (btController.Text == "Connect 3D Controller")
{
device = new TDxInput.Device();
sensor = new TDxInput.Sensor();
keyboard = new TDxInput.Keyboard();
keyboard.KeyDown += new TDxInput._IKeyboardEvents_KeyDownEventHandler(keyboard_KeyDown);
//sensor.SensorInput += new TDxInput._ISensorEvents_SensorInputEventHandler(sensor_SensorInput);
device.Connect();
switch (device.Type)
{
case 0: MessageBox.Show("Unknown Controller Type connected", "OE14_502 GUI");
break;
case 4: MessageBox.Show("SpaceExplorer Controller Type connected", "OE14_502 GUI");
break;
case 6: MessageBox.Show("SpaceNavigator Controller Type connected", "OE14_502 GUI");
break;
case 25: MessageBox.Show("SpaceTraveller Controller Type connected", "OE14_502 GUI");
break;
case 29: MessageBox.Show("SpacePilot Controller Type connected", "OE14_502 GUI");
break;
default:
break;
}
btController.Text = "Disconnect 3D Controller";
}
}
catch (Exception ex)
{
}
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void frmMain_FormClosing(object sender, f ormClosingEventArgs e)
{
device.Disconnect();
}
}
}
Any comments on why its not working and any tips on improving it?
thanks for any help
Sandyw
No reaction to key presses etc
Moderator: Moderators
Hi sandyw,
You're creating disjoint instances of the Device, Sensor and Keyboard objects. You should only create a "Device" and retrieve the references to the other objects from it.
We have a C# sample on the SDK page. There are also C# examples on this Forum (refer to this post).
You're creating disjoint instances of the Device, Sensor and Keyboard objects. You should only create a "Device" and retrieve the references to the other objects from it.
We have a C# sample on the SDK page. There are also C# examples on this Forum (refer to this post).
Nuno Gomes
No reaction to key presses etc
Hello jwick, gnomes
Problem Solved.
It's obvios when it's pointed out. More care next time I think
Thank you for your help.
Also thanks for the tip about the buttons.
sandyw
Problem Solved.
It's obvios when it's pointed out. More care next time I think
Thank you for your help.
Also thanks for the tip about the buttons.
sandyw
sandyw