name explains most of it, basically i am using this code:
It detects button presses from a steering wheel, this is the button select feature from my game controller interface program.
Basically i want to know if i can use 'foreach' to make it so i only have to have one if statement.
i have tried:
but it seems to not work, i would be greatful for any help available!
thanks
Peter
private void timer2_Tick(object sender, EventArgs e)
{
Poll();
byte[] joystickbtn = state.GetButtons();
buttons = new bool[joystickbtn.Length];
int j = 0;
foreach (byte button in joystickbtn)
{
buttons[j] = button >= 128;
j++;
}
if (buttons[16])
{
label1.Text = ("16");
timer2.Enabled = false;
}
if (buttons[17])
{
label1.Text = ("17");
timer2.Enabled = false;
}
if (buttons[18])
{
label1.Text = ("18");
timer2.Enabled = false;
}
if (buttons[19])
{
label1.Text = ("19");
timer2.Enabled = false;
}
}
It detects button presses from a steering wheel, this is the button select feature from my game controller interface program.
Basically i want to know if i can use 'foreach' to make it so i only have to have one if statement.
i have tried:
if (buttons[j])
{
label1.Text = (j);
timer2.Enabled = false;
}
but it seems to not work, i would be greatful for any help available!
thanks
Peter