I will use that for the starting point thank you and here is the code if anyone is interested.
Code:
public Form1()
{
InitializeComponent();
BootGamePort();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
BootGamePort();
}
Joystick mainScouter;
JoystickState state = new JoystickState();
void BootGamePort()
{
DirectInput dinput = new DirectInput();
foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly))
{
try
{
if (count == 0)
{
mainScouter = new Joystick(dinput, device.InstanceGuid);
}
count = 1;
break;
}
catch (DirectInputException)
{
}
}
if (mainScouter == null)
{
return;
}
foreach (DeviceObjectInstance deviceObject in mainScouter.GetObjects())
{
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)
mainScouter.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-100, 100);
}
mainScouter.Acquire();
}
public void timer1_Tick(object sender, EventArgs e)
{
if (mainScouter.Acquire().IsFailure)
{
return;
}
if (mainScouter.Poll().IsFailure)
{
return;
}
state = mainScouter.GetCurrentState();
if (Result.Last.IsFailure)
{
return;
}
bool[] buttons = state.GetButtons();
String strText = "";
for (int b = 0; b < buttons.Length; b++)
{
if (buttons[b])
{
strText += b.ToString("00 ", CultureInfo.CurrentCulture);
lblbuttons.Text = strText;
}
}