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
{
device.Disconnect();
}
}
}
Any comments on why its not working and any tips on improving it?
thanks for any help
Sandyw
