directinput not working!
I'm trying to get directinput working but for some reason it just does not work.
Why doesn't the following code cause any visible results in the textbox keyboardData? I had a previous program i wrote that used directinput,, but it was much more complex and for the most part i just copied the basic idea behind what i did then and that works, but for some reason this doesn't work :(
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DXInput = Microsoft.DirectX.DirectInput;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace DirectInput
{
public partial class Form1 : Form
{
public DXInput.Device myKeyboardDevice;
public Form1()
{
InitializeComponent();
InitializeKeyboard();
}
public void InitializeKeyboard()
{
myKeyboardDevice = new DXInput.Device(DXInput.SystemGuid.Keyboard);
myKeyboardDevice.SetCooperativeLevel(this, DXInput.CooperativeLevelFlags.Background | DXInput.CooperativeLevelFlags.NonExclusive);
myKeyboardDevice.Acquire();
}
public void ReadKeyboard()
{
DXInput.KeyboardState keys = myKeyboardDevice.GetCurrentKeyboardState();
if (keys[DXInput.Key.T])
keyboardData.Text = "T";
}
protected override void OnPaint(PaintEventArgs e)
{
ReadKeyboard();
}
}
}
And here is the main program file:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DirectInput
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Any idea what is wrong, this has been bugging me for days now, and i just can't fix it.

